<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>humarobotics-wifiblock.h</h1>  </div>
</div>
<div class="contents">
<a href="humarobotics-wifiblock_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*!@addtogroup other</span>
<a name="l00002"></a>00002 <span class="comment"> * @{</span>
<a name="l00003"></a>00003 <span class="comment"> * @defgroup HRWB HumaRobotics WiFiBlock</span>
<a name="l00004"></a>00004 <span class="comment"> * HumaBotics WiFiBlock Sensor</span>
<a name="l00005"></a>00005 <span class="comment"> * @{</span>
<a name="l00006"></a>00006 <span class="comment"> */</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="comment">/*</span>
<a name="l00009"></a>00009 <span class="comment"> * $Id: humarobotics-wifiblock.h 133 2013-03-10 15:15:38Z xander $</span>
<a name="l00010"></a>00010 <span class="comment"> */</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#ifndef __HRWB_H__</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define __HRWB_H__</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="comment">/** \file humarobotics-wifiblock.h</span>
<a name="l00015"></a>00015 <span class="comment"> * \brief HumaRobotics WiFiBlock driver</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * humarobotics-wifiblock.h provides an API for the HumaRobotics WiFiBlock Sensor.  This program</span>
<a name="l00018"></a>00018 <span class="comment"> * demonstrates how to use that API.</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * Changelog:</span>
<a name="l00021"></a>00021 <span class="comment"> * - 0.1: Initial release</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> * Credits:</span>
<a name="l00024"></a>00024 <span class="comment"> * - Big thanks to HumaRobotics for providing me with the hardware necessary to write and test this.</span>
<a name="l00025"></a>00025 <span class="comment"> *</span>
<a name="l00026"></a>00026 <span class="comment"> * License: You may use this code as you wish, provided you give credit where its due.</span>
<a name="l00027"></a>00027 <span class="comment"> *</span>
<a name="l00028"></a>00028 <span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="comment"> * \author Xander Soldaat (xander_at_botbench.com)</span>
<a name="l00031"></a>00031 <span class="comment"> * \date 02 April 2012</span>
<a name="l00032"></a>00032 <span class="comment"> * \version 0.1</span>
<a name="l00033"></a>00033 <span class="comment"> * \example humarobotics-wifiblock-test1.c</span>
<a name="l00034"></a>00034 <span class="comment"> */</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#pragma systemFile</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="preprocessor">#ifndef __COMMON_H__</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="common_8h.html" title="Commonly used functions used by drivers.">common.h</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#endif</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 
<a name="l00043"></a><a class="code" href="group___h_r_w_b.html#ga548a056a3a942b82993ad2d3ebefb22f">00043</a> <span class="preprocessor">#define HRWB_I2C_ADDR               0x20      </span><span class="comment">/*!&lt; WiFiBlock I2C address */</span>
<a name="l00044"></a><a class="code" href="group___h_r_w_b.html#ga6296663d4eb46220970fc210bcfe7ef8">00044</a> <span class="preprocessor">#define HRWB_SIMPLE_WRITE           0x01      </span><span class="comment">/*!&lt; Command for a simple write */</span>
<a name="l00045"></a><a class="code" href="group___h_r_w_b.html#ga48ef04ac1663530ad290365ddf158e2f">00045</a> <span class="preprocessor">#define HRWB_MASKED_WRITE           0x02      </span><span class="comment">/*!&lt; Command for a masked write */</span>
<a name="l00046"></a>00046 
<a name="l00047"></a><a class="code" href="group___h_r_w_b.html#ga04ac32bb96f353ff11dd4fc2d068c113">00047</a> <span class="preprocessor">#define HRWB_SENSORTYPE             0x0008    </span><span class="comment">/*!&lt; Register for Sensortype - WIFI */</span>
<a name="l00048"></a><a class="code" href="group___h_r_w_b.html#ga5c5be32eddde62186fae481b78f364ea">00048</a> <span class="preprocessor">#define HRWB_BATTLVL                0x000C    </span><span class="comment">/*!&lt; Register for battery level in 0.1V */</span>
<a name="l00049"></a>00049 
<a name="l00050"></a><a class="code" href="group___h_r_w_b.html#ga2afbd442d6e578dfd2d5fde12c43e713">00050</a> <span class="preprocessor">#define HRWB_HTTP_RESULT_CODE       0x001F    </span><span class="comment">/*!&lt; Register for HTTP result code */</span>
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="group___h_r_w_b.html#gaab85d73aba3db566b7ab538a3f6ab81b">00052</a> <span class="preprocessor">#define HRWB_RESET                  0x000E    </span><span class="comment">/*!&lt; Register to reset the WiFiblock */</span>
<a name="l00053"></a><a class="code" href="group___h_r_w_b.html#ga3834577d8f0f4599a7d108b2e15fe365">00053</a> <span class="preprocessor">#define HRWB_RESET_WIFIBLOCK        0x00      </span><span class="comment">/*!&lt; Command to reset the WiFiblock */</span>
<a name="l00054"></a><a class="code" href="group___h_r_w_b.html#ga9e21a62d2788faf6d3328a00d2f3baab">00054</a> <span class="preprocessor">#define HRWB_RESET_ERRORCODE        0x01      </span><span class="comment">/*!&lt; Command to reset the error code WiFiblock */</span>
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="comment">// WiFi connection related</span>
<a name="l00057"></a><a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">00057</a> <span class="preprocessor">#define HRWB_WIFI_STATUS            0x0200    </span><span class="comment">/*!&lt; Register for WiFi Status - see HRWB_WIFI_STATUS_* for bit masks */</span>
<a name="l00058"></a><a class="code" href="group___h_r_w_b.html#ga2e4b7312d1c2849b5e810bb8b2a63e0f">00058</a> <span class="preprocessor">#define HRWB_WIFI_SIGNAL            0x0201    </span><span class="comment">/*!&lt; Register for signal strength */</span>
<a name="l00059"></a><a class="code" href="group___h_r_w_b.html#gaf0a94416246056eef2a340fd0bb040b0">00059</a> <span class="preprocessor">#define HRWB_WIFI_SSID              0x0202    </span><span class="comment">/*!&lt; Register for SSID */</span>
<a name="l00060"></a><a class="code" href="group___h_r_w_b.html#gaf8cc035c9e680217d2bf57d5cd085c83">00060</a> <span class="preprocessor">#define HRWB_WIFI_IP_ADDR           0x0222    </span><span class="comment">/*!&lt; Register for IPv4 address */</span>
<a name="l00061"></a><a class="code" href="group___h_r_w_b.html#ga1d2d9ca4db96d5ab508d296d8e28eff7">00061</a> <span class="preprocessor">#define HRWB_WIFI_IP_MASK           0x0226    </span><span class="comment">/*!&lt; Register for Netmask */</span>
<a name="l00062"></a><a class="code" href="group___h_r_w_b.html#ga168bdb2de73c0a907878eb46df0e356a">00062</a> <span class="preprocessor">#define HRWB_WIFI_IP_GATEWAY        0x022A    </span><span class="comment">/*!&lt; Register for default gateway */</span>
<a name="l00063"></a><a class="code" href="group___h_r_w_b.html#ga127f77f0205c98d8855f6893dee444b6">00063</a> <span class="preprocessor">#define HRWB_WIFI_SECURITY_TYPE     0x022E    </span><span class="comment">/*!&lt; Register for WiFi security type - see HRWB_SECURITY_*  for values */</span>
<a name="l00064"></a><a class="code" href="group___h_r_w_b.html#ga29f211ff2e662b45dc09981e01cf3bdc">00064</a> <span class="preprocessor">#define HRWB_WIFI_SECURITY_KEY      0x022F    </span><span class="comment">/*!&lt; Register for WiFi key */</span>
<a name="l00065"></a><a class="code" href="group___h_r_w_b.html#gafe9bd4813ad80d9cc42fc0d5bf924820">00065</a> <span class="preprocessor">#define HRWB_WIFI_SCANRESULT        0x026F    </span><span class="comment">/*!&lt; Register for number of SSIDs found after a scan */</span>
<a name="l00066"></a><a class="code" href="group___h_r_w_b.html#gac5cb9193217aef1a40771280bf0f88d1">00066</a> <span class="preprocessor">#define HRWB_WIFI_SCANSEL           0x0270    </span><span class="comment">/*!&lt; Register for selecting the SSID to get more info on */</span>
<a name="l00067"></a><a class="code" href="group___h_r_w_b.html#ga8988c4665a05503a1a8b20a10d8347cf">00067</a> <span class="preprocessor">#define HRWB_WIFI_SCANSIGNAL        0x0271    </span><span class="comment">/*!&lt; Register for the signal strength of the specified SSID */</span>
<a name="l00068"></a><a class="code" href="group___h_r_w_b.html#gafc250e7ef2f18fd0b06b1d6d4a1fa563">00068</a> <span class="preprocessor">#define HRWB_WIFI_SCANSEC           0x0272    </span><span class="comment">/*!&lt; Register for the security type of the specified SSID */</span>
<a name="l00069"></a><a class="code" href="group___h_r_w_b.html#ga22b92d4147269a708469dc21a6a81519">00069</a> <span class="preprocessor">#define HRWB_WIFI_SCANSSID          0x0273    </span><span class="comment">/*!&lt; Register for specifying the SSID to scan */</span>
<a name="l00070"></a>00070 
<a name="l00071"></a><a class="code" href="group___h_r_w_b.html#ga9abd1e799800f57443b81d2940d27ede">00071</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_ENABLE     0x01      </span><span class="comment">/*!&lt; Bit mask for selecting WiFi status */</span>
<a name="l00072"></a><a class="code" href="group___h_r_w_b.html#gaaf0701da2df31629a835b2b1dca36e4f">00072</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_SAVE_CONF  0x02      </span><span class="comment">/*!&lt; Bit mask for selecting command to save current configuration */</span>
<a name="l00073"></a><a class="code" href="group___h_r_w_b.html#ga33e0c4df34dc73f14d41f25e39a4b2fb">00073</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_START_SCAN 0x04      </span><span class="comment">/*!&lt; Bit mask for selecting command to start scanning network */</span>
<a name="l00074"></a><a class="code" href="group___h_r_w_b.html#ga079b7f1798f349ca6fdfd769bc80b61f">00074</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_SCAN_DONE  0x08      </span><span class="comment">/*!&lt; Bit mask for selecting whether scan is done */</span>
<a name="l00075"></a><a class="code" href="group___h_r_w_b.html#ga7fcc152ffca25463e0d1942e5923f634">00075</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_CONN_STAT  0x10      </span><span class="comment">/*!&lt; Bit mask for selecting status of the current WiFi connection */</span>
<a name="l00076"></a><a class="code" href="group___h_r_w_b.html#ga3515a5bce62e46a19722b956a7886cea">00076</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_RESERVED   0x20      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00077"></a><a class="code" href="group___h_r_w_b.html#ga3eb43fd6520957a65960861e6687c4cf">00077</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_RECONN     0x40      </span><span class="comment">/*!&lt; Bit mask for selecting whether or not to reconnect when disconnected */</span>
<a name="l00078"></a><a class="code" href="group___h_r_w_b.html#ga248b1fde63ff7b75580d4b29217bb074">00078</a> <span class="preprocessor">#define HRWB_WIFI_STATUS_DEL_CONF   0x80      </span><span class="comment">/*!&lt; Bit mask for selecting command to delete current configuration */</span>
<a name="l00079"></a>00079 
<a name="l00080"></a><a class="code" href="group___h_r_w_b.html#ga06dbc7ecfc86d60b7690f002d6e2ed33">00080</a> <span class="preprocessor">#define HRWB_SECURITY_OPEN          0x00      </span><span class="comment">/*!&lt; HRWB_WIFI_SECURITY_TYPE value for Open Network (no crypto) */</span>
<a name="l00081"></a><a class="code" href="group___h_r_w_b.html#ga3cb8146285bdbe1452146507cf5b6d65">00081</a> <span class="preprocessor">#define HRWB_SECURITY_WEP           0x01      </span><span class="comment">/*!&lt; HRWB_WIFI_SECURITY_TYPE value for WEP crypto */</span>
<a name="l00082"></a><a class="code" href="group___h_r_w_b.html#ga3d9561f134ef8c4eeba475de1d7c529c">00082</a> <span class="preprocessor">#define HRWB_SECURITY_WPA           0x02      </span><span class="comment">/*!&lt; HRWB_WIFI_SECURITY_TYPE value for WPA */</span>
<a name="l00083"></a><a class="code" href="group___h_r_w_b.html#ga77af109f3bad79e66f56f2a7941c3a30">00083</a> <span class="preprocessor">#define HRWB_SECURITY_WPA2          0x03      </span><span class="comment">/*!&lt; HRWB_WIFI_SECURITY_TYPE value for WPA2 */</span>
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 <span class="comment">// HTTP GET related</span>
<a name="l00086"></a><a class="code" href="group___h_r_w_b.html#ga4bd26a67c966bd8b5254d5fcf156725e">00086</a> <span class="preprocessor">#define HRWB_GET_STATUS             0x1000    </span><span class="comment">/*!&lt; Register for status of GET command - see HRWB_GET_STATUS_* for bit masks */</span>
<a name="l00087"></a><a class="code" href="group___h_r_w_b.html#ga3a8b05801cca5bb25c82addb9befe569">00087</a> <span class="preprocessor">#define HRWB_GET_LENGTH             0x1001    </span><span class="comment">/*!&lt; Register for received data length */</span>
<a name="l00088"></a><a class="code" href="group___h_r_w_b.html#gad10bd1972de60eb5e0aef3af95a8183d">00088</a> <span class="preprocessor">#define HRWB_GET_IP_ADDR            0x1002    </span><span class="comment">/*!&lt; Register for IP address to send request to */</span>
<a name="l00089"></a><a class="code" href="group___h_r_w_b.html#gaf9311e92f8f5cb0e9355bd91545bc995">00089</a> <span class="preprocessor">#define HRWB_GET_PORT               0x1006    </span><span class="comment">/*!&lt; Register for port to send request to */</span>
<a name="l00090"></a><a class="code" href="group___h_r_w_b.html#ga2694632bffe558b5159aa0b4dfa187bc">00090</a> <span class="preprocessor">#define HRWB_GET_URL                0x1008    </span><span class="comment">/*!&lt; Register for URL (everything after the host name) */</span>
<a name="l00091"></a><a class="code" href="group___h_r_w_b.html#ga4e4463412c77b1b9fb14fadaff83d3d2">00091</a> <span class="preprocessor">#define HRWB_GET_DATA               0x1048    </span><span class="comment">/*!&lt; Register for received data */</span>
<a name="l00092"></a>00092 
<a name="l00093"></a><a class="code" href="group___h_r_w_b.html#ga81cee7f8ba8308eccc51b9fe8773254f">00093</a> <span class="preprocessor">#define HRWB_GET_STATUS_READY       0x01      </span><span class="comment">/*!&lt; Bit mask for GET port readiness status */</span>
<a name="l00094"></a><a class="code" href="group___h_r_w_b.html#ga1461de05360c3e069be4c5670fece913">00094</a> <span class="preprocessor">#define HRWB_GET_STATUS_RESERVED1   0x02      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00095"></a><a class="code" href="group___h_r_w_b.html#gac35856e738d91770f8110df0572b7b43">00095</a> <span class="preprocessor">#define HRWB_GET_STATUS_SEND_REQ    0x04      </span><span class="comment">/*!&lt; Bit mask for sending the GET request*/</span>
<a name="l00096"></a><a class="code" href="group___h_r_w_b.html#gad89462f276459994f24dfa0dfc8a3968">00096</a> <span class="preprocessor">#define HRWB_GET_STATUS_REQ_DONE    0x08      </span><span class="comment">/*!&lt; Bit mask for checking whether GET request is done */</span>
<a name="l00097"></a><a class="code" href="group___h_r_w_b.html#ga22b23a63f55863ff42921a97a396980a">00097</a> <span class="preprocessor">#define HRWB_GET_STATUS_RESERVED2   0x10      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00098"></a><a class="code" href="group___h_r_w_b.html#ga674acef6b5f86d6454242a95f834ce55">00098</a> <span class="preprocessor">#define HRWB_GET_STATUS_RESERVED3   0x20      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00099"></a><a class="code" href="group___h_r_w_b.html#ga31c571379c9590d884cc70f17ce61011">00099</a> <span class="preprocessor">#define HRWB_GET_STATUS_RESERVED4   0x40      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00100"></a><a class="code" href="group___h_r_w_b.html#ga96cf5e7095b5a373a924ab76074f4936">00100</a> <span class="preprocessor">#define HRWB_GET_STATUS_REQ_ERROR   0x80      </span><span class="comment">/*!&lt; Bit mask for checking if an error has occurred */</span>
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 <span class="comment">// HTTP POST related</span>
<a name="l00103"></a><a class="code" href="group___h_r_w_b.html#ga7f687ee86db4390d1d5cb5271a41548a">00103</a> <span class="preprocessor">#define HRWB_POST_STATUS            0x2000    </span><span class="comment">/*!&lt; Register for status of POST command - see HRWB_POST_STATUS_* for bit masks */</span>
<a name="l00104"></a><a class="code" href="group___h_r_w_b.html#gab361a4cf9ff42e748e9767679daa7ad8">00104</a> <span class="preprocessor">#define HRWB_POST_LENGTH            0x2001    </span><span class="comment">/*!&lt; Register for POST data length */</span>
<a name="l00105"></a><a class="code" href="group___h_r_w_b.html#ga24ae5d966024071b02ce3baee2605d69">00105</a> <span class="preprocessor">#define HRWB_POST_IP_ADDR           0x2002    </span><span class="comment">/*!&lt; Register for IP address to send request to */</span>
<a name="l00106"></a><a class="code" href="group___h_r_w_b.html#gac2530c07629b55b57761aa141c774aca">00106</a> <span class="preprocessor">#define HRWB_POST_PORT              0x2006    </span><span class="comment">/*!&lt; Register for port to send request to */</span>
<a name="l00107"></a><a class="code" href="group___h_r_w_b.html#ga99cdc2184d7073f1c1f20f60723cadb0">00107</a> <span class="preprocessor">#define HRWB_POST_URL               0x2008    </span><span class="comment">/*!&lt; Register for URL (everything after the host name) */</span>
<a name="l00108"></a><a class="code" href="group___h_r_w_b.html#gaa8d64c2edecfb8fc26acd1306c68d214">00108</a> <span class="preprocessor">#define HRWB_POST_DATA              0x2048    </span><span class="comment">/*!&lt; Register for POST data */</span>
<a name="l00109"></a>00109 
<a name="l00110"></a><a class="code" href="group___h_r_w_b.html#ga17d743fcff07cf727fb6b84fbd4914c3">00110</a> <span class="preprocessor">#define HRWB_POST_STATUS_READY      0x01      </span><span class="comment">/*!&lt; Bit mask for POST port readiness status */</span>
<a name="l00111"></a><a class="code" href="group___h_r_w_b.html#gabc8ae56d65b65eaf0e4220a3c1437cd1">00111</a> <span class="preprocessor">#define HRWB_POST_STATUS_RESERVED1  0x02      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00112"></a><a class="code" href="group___h_r_w_b.html#gae586eba23c128a4c569bf1b606450613">00112</a> <span class="preprocessor">#define HRWB_POST_STATUS_SEND_REQ   0x04      </span><span class="comment">/*!&lt; Bit mask for sending the POST request*/</span>
<a name="l00113"></a><a class="code" href="group___h_r_w_b.html#ga38ace177506cf66371b447912c5fc8bc">00113</a> <span class="preprocessor">#define HRWB_POST_STATUS_REQ_DONE   0x08      </span><span class="comment">/*!&lt; Bit mask for checking whether POST request is done */</span>
<a name="l00114"></a><a class="code" href="group___h_r_w_b.html#gaebb9261535d6a629dca490866e784b8a">00114</a> <span class="preprocessor">#define HRWB_POST_STATUS_EN_FL_STO  0x10      </span><span class="comment">/*!&lt; Bit mask to store POST requests in the dataflash in case of network loss */</span>
<a name="l00115"></a><a class="code" href="group___h_r_w_b.html#ga2160429e03d4f8cb1dadd71c3d1007af">00115</a> <span class="preprocessor">#define HRWB_POST_STATUS_EN_FL_RTX  0x20      </span><span class="comment">/*!&lt; Bit mask to store POST requests in the DataFlash in case of network loss</span>
<a name="l00116"></a>00116 <span class="comment">                                                   and then automatically retransmits them when the network is up again */</span>
<a name="l00117"></a><a class="code" href="group___h_r_w_b.html#gaf02979d64f340d152fa7f1b5fa938147">00117</a> <span class="preprocessor">#define HRWB_POST_STATUS_RESERVED2  0x40      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00118"></a><a class="code" href="group___h_r_w_b.html#ga7805266f0220885fec9b5194e127d98a">00118</a> <span class="preprocessor">#define HRWB_POST_STATUS_REQ_ERROR  0x80      </span><span class="comment">/*!&lt; Bit mask for checking if an error has occurred */</span>
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 <span class="comment">// TCP related</span>
<a name="l00121"></a><a class="code" href="group___h_r_w_b.html#gae68063dc3dcad3f215a1d7c076d274b0">00121</a> <span class="preprocessor">#define HRWB_TCP_STATUS             0x4000    </span><span class="comment">/*!&lt; Register for status of TCP command - see HRWB_TCP_STATUS_* for bit masks */</span>
<a name="l00122"></a><a class="code" href="group___h_r_w_b.html#ga4cfb14cccf826cfc81f6aca739698a2f">00122</a> <span class="preprocessor">#define HRWB_TCP_IP_ADDR            0x4001    </span><span class="comment">/*!&lt; Register for IP address to send request to */</span>
<a name="l00123"></a><a class="code" href="group___h_r_w_b.html#ga5424ffaf440a8969fb61872b9dd27cc7">00123</a> <span class="preprocessor">#define HRWB_TCP_PORT               0x4005    </span><span class="comment">/*!&lt; Register for port to send request to */</span>
<a name="l00124"></a><a class="code" href="group___h_r_w_b.html#gab7316e7c92ab2e4c8512d0b90b12d53e">00124</a> <span class="preprocessor">#define HRWB_TCP_TX_LENGTH          0x4007    </span><span class="comment">/*!&lt; Register for tramsmitted data length */</span>
<a name="l00125"></a><a class="code" href="group___h_r_w_b.html#gae47623c8e63e1ba38d2ef2c607043707">00125</a> <span class="preprocessor">#define HRWB_TCP_TX_DATA            0x4008    </span><span class="comment">/*!&lt; Register for tramsmitted data */</span>
<a name="l00126"></a><a class="code" href="group___h_r_w_b.html#ga3a3a9e7b5012963750ed7cd5d6ec7de9">00126</a> <span class="preprocessor">#define HRWB_TCP_RX_LENGTH          0x4028    </span><span class="comment">/*!&lt; Register for received data length */</span>
<a name="l00127"></a><a class="code" href="group___h_r_w_b.html#ga20a4a2fc472c6a3ddc9b55029c0240a5">00127</a> <span class="preprocessor">#define HRWB_TCP_RX_DATA            0x4029    </span><span class="comment">/*!&lt; Register for received data */</span>
<a name="l00128"></a>00128 
<a name="l00129"></a><a class="code" href="group___h_r_w_b.html#gac92fd33aefa1c0f1ef72f865bb631e85">00129</a> <span class="preprocessor">#define HRWB_TCP_STATUS_READY       0x01      </span><span class="comment">/*!&lt; Bit mask for TCP port readiness status */</span>
<a name="l00130"></a><a class="code" href="group___h_r_w_b.html#ga0d60f985390f06311e15a4b9dca964bc">00130</a> <span class="preprocessor">#define HRWB_TCP_STATUS_SEND_REQ    0x02      </span><span class="comment">/*!&lt; Bit mask for sending the TCP request*/</span>
<a name="l00131"></a><a class="code" href="group___h_r_w_b.html#ga4e4dd56280dc0b77981313f42b9c1c3a">00131</a> <span class="preprocessor">#define HRWB_TCP_STATUS_REQ_DONE    0x04      </span><span class="comment">/*!&lt; Bit mask for checking whether TCP request is done */</span>
<a name="l00132"></a><a class="code" href="group___h_r_w_b.html#ga8a9e5b0f71b30120679fd7fd90a5e690">00132</a> <span class="preprocessor">#define HRWB_TCP_STATUS_RESERVED1   0x08      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00133"></a><a class="code" href="group___h_r_w_b.html#ga1296d0f5113f03447b2361bcb6a7877f">00133</a> <span class="preprocessor">#define HRWB_TCP_STATUS_RESERVED2   0x10      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00134"></a><a class="code" href="group___h_r_w_b.html#gaf40203b04cd508ae8b77d74bcd286ed9">00134</a> <span class="preprocessor">#define HRWB_TCP_STATUS_RESERVED3   0x20      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00135"></a><a class="code" href="group___h_r_w_b.html#ga4e657bfcc733842cb8e02b460f5b1d39">00135</a> <span class="preprocessor">#define HRWB_TCP_STATUS_RESERVED4   0x40      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00136"></a><a class="code" href="group___h_r_w_b.html#ga3d56950b17a9b8bea98a9bfd88bf2d2b">00136</a> <span class="preprocessor">#define HRWB_TCP_STATUS_REQ_ERROR   0x80      </span><span class="comment">/*!&lt; Bit mask for checking if an error has occurred */</span>
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 <span class="comment">// UDP related</span>
<a name="l00139"></a><a class="code" href="group___h_r_w_b.html#gaa2a4e5ec89fd20f725158818684cfe55">00139</a> <span class="preprocessor">#define HRWB_UDP_STATUS             0x3000    </span><span class="comment">/*!&lt; Register for status of UDP command - see HRWB_UDP_STATUS_* for bit masks */</span>
<a name="l00140"></a><a class="code" href="group___h_r_w_b.html#ga1ac8093a557d797d279f340ccf268a00">00140</a> <span class="preprocessor">#define HRWB_UDP_IP_ADDR            0x3001    </span><span class="comment">/*!&lt; Register for IP address to send request to */</span>
<a name="l00141"></a><a class="code" href="group___h_r_w_b.html#ga6dd3ba43103173e49a4a9eecb0a69664">00141</a> <span class="preprocessor">#define HRWB_UDP_DPORT              0x3005    </span><span class="comment">/*!&lt; Register for port to send request to */</span>
<a name="l00142"></a><a class="code" href="group___h_r_w_b.html#gaafb3baddc2e5ae7ebe5aadaa8c8825fd">00142</a> <span class="preprocessor">#define HRWB_UDP_SPORT              0x3007    </span><span class="comment">/*!&lt; Register for port to send request from */</span>
<a name="l00143"></a><a class="code" href="group___h_r_w_b.html#ga3791be776cf98565408cce1dd1a9b8d1">00143</a> <span class="preprocessor">#define HRWB_UDP_TX_LENGTH          0x3009    </span><span class="comment">/*!&lt; Register for tramsmitted data length */</span>
<a name="l00144"></a><a class="code" href="group___h_r_w_b.html#ga33718caa5501b3432a8104fa47fe43e2">00144</a> <span class="preprocessor">#define HRWB_UDP_TX_DATA            0x300A    </span><span class="comment">/*!&lt; Register for tramsmitted data */</span>
<a name="l00145"></a><a class="code" href="group___h_r_w_b.html#ga25cac5b6ff154c5cb954fd71b590f0c8">00145</a> <span class="preprocessor">#define HRWB_UDP_RX_LENGTH          0x302A    </span><span class="comment">/*!&lt; Register for received data length */</span>
<a name="l00146"></a><a class="code" href="group___h_r_w_b.html#gaed05706029146c07f0fb8c628916e6a1">00146</a> <span class="preprocessor">#define HRWB_UDP_RX_DATA            0x302B    </span><span class="comment">/*!&lt; Register for received data */</span>
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="group___h_r_w_b.html#gac55a869326d86b0a4cecc20764fad834">00148</a> <span class="preprocessor">#define HRWB_UDP_STATUS_READY       0x01      </span><span class="comment">/*!&lt; Bit mask for UDP port readiness status */</span>
<a name="l00149"></a><a class="code" href="group___h_r_w_b.html#gacaeeffdcbfe63673d18be3aec8177e56">00149</a> <span class="preprocessor">#define HRWB_UDP_STATUS_SEND_REQ    0x02      </span><span class="comment">/*!&lt; Bit mask for sending the UDP request*/</span>
<a name="l00150"></a><a class="code" href="group___h_r_w_b.html#gabc5bb1d4cd7da104af75774cdcf05368">00150</a> <span class="preprocessor">#define HRWB_UDP_STATUS_REQ_DONE    0x04      </span><span class="comment">/*!&lt; Bit mask for checking whether UDP request is done */</span>
<a name="l00151"></a><a class="code" href="group___h_r_w_b.html#ga5ad70b114d0cbeef1005e40651317a3f">00151</a> <span class="preprocessor">#define HRWB_UDP_STATUS_RXD_RDY     0x08      </span><span class="comment">/*!&lt; Bit mask for checking whether UDP data is ready for reading */</span>
<a name="l00152"></a><a class="code" href="group___h_r_w_b.html#ga043ed3d5c719d1bf213c421d876d911b">00152</a> <span class="preprocessor">#define HRWB_UDP_STATUS_RXD_READ    0x10      </span><span class="comment">/*!&lt; Bit mask start reading UDP data */</span>
<a name="l00153"></a><a class="code" href="group___h_r_w_b.html#gaecb32411001861f36a5772bd2d202fa6">00153</a> <span class="preprocessor">#define HRWB_UDP_STATUS_RESERVED1   0x20      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00154"></a><a class="code" href="group___h_r_w_b.html#ga9bd95d59d5e745d3822cb93cfcee2301">00154</a> <span class="preprocessor">#define HRWB_UDP_STATUS_RESERVED2   0x40      </span><span class="comment">/*!&lt; RESERVED */</span>
<a name="l00155"></a><a class="code" href="group___h_r_w_b.html#gae2fafb6f65bb3d5eda092236c499f1d7">00155</a> <span class="preprocessor">#define HRWB_UDP_STATUS_REQ_ERROR   0x80      </span><span class="comment">/*!&lt; Bit mask for checking if an error has occurred */</span>
<a name="l00156"></a>00156 
<a name="l00157"></a><a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">00157</a> <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>;       <span class="comment">/*!&lt; Array to hold I2C command data */</span>
<a name="l00158"></a><a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">00158</a> <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>;         <span class="comment">/*!&lt; Array to hold I2C reply data */</span>
<a name="l00159"></a><a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">00159</a> <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>;          <span class="comment">/*!&lt; Array to hold scratch data */</span>
<a name="l00160"></a><a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">00160</a> <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>;    <span class="comment">/*!&lt; Array to hold scratch data, only more of it */</span>
<a name="l00161"></a>00161 
<a name="l00162"></a>00162 
<a name="l00163"></a><a class="code" href="structt_network_info.html">00163</a> <span class="keyword">typedef</span> <span class="keyword">struct                    </span><span class="comment">/*!&lt; Struct to hold network config information */</span>
<a name="l00164"></a>00164 {
<a name="l00165"></a><a class="code" href="structt_network_info.html#a3f000c56bd8458cbf6b9cc3c76685a2c">00165</a>   <span class="keywordtype">string</span> <a class="code" href="structt_network_info.html#a3f000c56bd8458cbf6b9cc3c76685a2c">wifi_ssid</a>;               <span class="comment">/*!&lt; SSID (network name) to connect to */</span>
<a name="l00166"></a><a class="code" href="structt_network_info.html#adbc92e636f928aee80429e36e717a3c5">00166</a>   <span class="keywordtype">string</span> <a class="code" href="structt_network_info.html#adbc92e636f928aee80429e36e717a3c5">wifi_pass</a>;               <span class="comment">/*!&lt; WiFi network pass */</span>
<a name="l00167"></a><a class="code" href="structt_network_info.html#a3987dc1a3dbba53b106c2ed4332fc364">00167</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_network_info.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>;                     <span class="comment">/*!&lt; IP address to use */</span>
<a name="l00168"></a><a class="code" href="structt_network_info.html#a6b6ec939233a56041fceaf9865d0e171">00168</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_network_info.html#a6b6ec939233a56041fceaf9865d0e171">netmask</a>;                <span class="comment">/*!&lt; netmask to use */</span>
<a name="l00169"></a><a class="code" href="structt_network_info.html#aff136b7050438924899191b52a061988">00169</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_network_info.html#aff136b7050438924899191b52a061988">gateway</a>;                <span class="comment">/*!&lt; defrault gateway to use */</span>
<a name="l00170"></a><a class="code" href="structt_network_info.html#aebfb3beb0bbd0f126f1c807e44431656">00170</a>   ubyte <a class="code" href="structt_network_info.html#aebfb3beb0bbd0f126f1c807e44431656">wifi_type</a>;                <span class="comment">/*!&lt; Crypto used on the network, see HRWB_SECURITY_* for options */</span>
<a name="l00171"></a>00171 } <a class="code" href="structt_network_info.html">tNetworkInfo</a>;
<a name="l00172"></a>00172 
<a name="l00173"></a>00173 <span class="comment">/*</span>
<a name="l00174"></a>00174 <span class="comment">typedef struct</span>
<a name="l00175"></a>00175 <span class="comment">{</span>
<a name="l00176"></a>00176 <span class="comment">  ubyte SSID[64];</span>
<a name="l00177"></a>00177 <span class="comment">  ubyte signalStrength;</span>
<a name="l00178"></a>00178 <span class="comment">  ubyte securityType;</span>
<a name="l00179"></a>00179 <span class="comment">} tSSIDInfo;</span>
<a name="l00180"></a>00180 <span class="comment">*/</span>
<a name="l00181"></a>00181 
<a name="l00182"></a>00182 
<a name="l00183"></a><a class="code" href="structt_get_request.html">00183</a> <span class="keyword">typedef</span> <span class="keyword">struct                    </span><span class="comment">/*!&lt; Struct to hold UDP connection info */</span>
<a name="l00184"></a>00184 {
<a name="l00185"></a><a class="code" href="structt_get_request.html#a3987dc1a3dbba53b106c2ed4332fc364">00185</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_get_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>;                     <span class="comment">/*!&lt; IP address to send request to */</span>
<a name="l00186"></a><a class="code" href="structt_get_request.html#a63c89c04d1feae07ca35558055155ffb">00186</a>   <span class="keywordtype">int</span> <a class="code" href="structt_get_request.html#a63c89c04d1feae07ca35558055155ffb">port</a>;                       <span class="comment">/*!&lt; port to send request to */</span>
<a name="l00187"></a><a class="code" href="structt_get_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">00187</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_get_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>;             <span class="comment">/*!&lt; URL (everything after the host name) */</span>
<a name="l00188"></a><a class="code" href="structt_get_request.html#a7dd77a48b3fc5e229f5f9db5bee8ca60">00188</a>   <a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a> <a class="code" href="structt_get_request.html#a7dd77a48b3fc5e229f5f9db5bee8ca60">RXData</a>;           <span class="comment">/*!&lt; Received data */</span>
<a name="l00189"></a><a class="code" href="structt_get_request.html#a751d3070e77ef824ec375a233d8cde1a">00189</a>   ubyte <a class="code" href="structt_get_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>;                <span class="comment">/*!&lt; Amount of received data */</span>
<a name="l00190"></a><a class="code" href="structt_get_request.html#a0bcbf737568b3f83477fd1e521f6c131">00190</a>   ubyte <a class="code" href="structt_get_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a>;              <span class="comment">/*!&lt; HTTP result code */</span>
<a name="l00191"></a>00191 } <a class="code" href="structt_get_request.html">tGetRequest</a>;
<a name="l00192"></a>00192 
<a name="l00193"></a>00193 
<a name="l00194"></a><a class="code" href="structt_post_request.html">00194</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00195"></a>00195 {
<a name="l00196"></a><a class="code" href="structt_post_request.html#a3987dc1a3dbba53b106c2ed4332fc364">00196</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_post_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>;                     <span class="comment">/*!&lt; IP address to send request to */</span>
<a name="l00197"></a><a class="code" href="structt_post_request.html#a63c89c04d1feae07ca35558055155ffb">00197</a>   <span class="keywordtype">int</span> <a class="code" href="structt_post_request.html#a63c89c04d1feae07ca35558055155ffb">port</a>;                       <span class="comment">/*!&lt; port to send request to */</span>
<a name="l00198"></a><a class="code" href="structt_post_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">00198</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_post_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>;             <span class="comment">/*!&lt; URL (everything after the host name) */</span>
<a name="l00199"></a><a class="code" href="structt_post_request.html#a6c093ddf7de5f28ffed73071e70b1232">00199</a>   <a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a> <a class="code" href="structt_post_request.html#a6c093ddf7de5f28ffed73071e70b1232">TXData</a>;           <span class="comment">/*!&lt; Data to be transmitted */</span>
<a name="l00200"></a><a class="code" href="structt_post_request.html#aa300ad171e0161e703a3d0c770ef09e1">00200</a>   ubyte <a class="code" href="structt_post_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>;                <span class="comment">/*!&lt; Amount of data to be transmitted */</span>
<a name="l00201"></a><a class="code" href="structt_post_request.html#a0bcbf737568b3f83477fd1e521f6c131">00201</a>   ubyte <a class="code" href="structt_post_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a>;              <span class="comment">/*!&lt; HTTP result code */</span>
<a name="l00202"></a>00202 } <a class="code" href="structt_post_request.html">tPostRequest</a>;
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 
<a name="l00205"></a><a class="code" href="structt_t_c_p_request.html">00205</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00206"></a>00206 {
<a name="l00207"></a><a class="code" href="structt_t_c_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">00207</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_t_c_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>;                     <span class="comment">/*!&lt; IP address to send request to */</span>
<a name="l00208"></a><a class="code" href="structt_t_c_p_request.html#a63c89c04d1feae07ca35558055155ffb">00208</a>   <span class="keywordtype">int</span> <a class="code" href="structt_t_c_p_request.html#a63c89c04d1feae07ca35558055155ffb">port</a>;                       <span class="comment">/*!&lt; port to send request to */</span>
<a name="l00209"></a><a class="code" href="structt_t_c_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">00209</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_t_c_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">TXData</a>;          <span class="comment">/*!&lt; Data to be transmitted */</span>
<a name="l00210"></a><a class="code" href="structt_t_c_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">00210</a>   ubyte <a class="code" href="structt_t_c_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>;                <span class="comment">/*!&lt; Amount of data to be transmitted */</span>
<a name="l00211"></a><a class="code" href="structt_t_c_p_request.html#acec89450ce66e3641999cc2f7e7e338c">00211</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_t_c_p_request.html#acec89450ce66e3641999cc2f7e7e338c">RXData</a>;          <span class="comment">/*!&lt; Data to be transmitted */</span>
<a name="l00212"></a><a class="code" href="structt_t_c_p_request.html#a751d3070e77ef824ec375a233d8cde1a">00212</a>   ubyte <a class="code" href="structt_t_c_p_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>;                <span class="comment">/*!&lt; Amount of data to be transmitted */</span>
<a name="l00213"></a><a class="code" href="structt_t_c_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">00213</a>   ubyte <a class="code" href="structt_t_c_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a>;              <span class="comment">/*!&lt; result code: 0 if everything was fine, 1 if there was an error */</span>
<a name="l00214"></a>00214 } <a class="code" href="structt_t_c_p_request.html">tTCPRequest</a>;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216 
<a name="l00217"></a><a class="code" href="structt_u_d_p_request.html">00217</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00218"></a>00218 {
<a name="l00219"></a><a class="code" href="structt_u_d_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">00219</a>   <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> <a class="code" href="structt_u_d_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>;                     <span class="comment">/*!&lt; IP address to send request to */</span>
<a name="l00220"></a><a class="code" href="structt_u_d_p_request.html#a32c63c3542a21dfdb3ed1164140c254f">00220</a>   <span class="keywordtype">int</span> <a class="code" href="structt_u_d_p_request.html#a32c63c3542a21dfdb3ed1164140c254f">sport</a>;                      <span class="comment">/*!&lt; port to send request from */</span>
<a name="l00221"></a><a class="code" href="structt_u_d_p_request.html#a32be3c23ead7f4709d3cece7cfe06d4e">00221</a>   <span class="keywordtype">int</span> <a class="code" href="structt_u_d_p_request.html#a32be3c23ead7f4709d3cece7cfe06d4e">dport</a>;                      <span class="comment">/*!&lt; port to send request to */</span>
<a name="l00222"></a><a class="code" href="structt_u_d_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">00222</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_u_d_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">TXData</a>;          <span class="comment">/*!&lt; Data to be transmitted */</span>
<a name="l00223"></a><a class="code" href="structt_u_d_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">00223</a>   ubyte <a class="code" href="structt_u_d_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>;                <span class="comment">/*!&lt; Amount of data to be transmitted */</span>
<a name="l00224"></a><a class="code" href="structt_u_d_p_request.html#acec89450ce66e3641999cc2f7e7e338c">00224</a>   <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> <a class="code" href="structt_u_d_p_request.html#acec89450ce66e3641999cc2f7e7e338c">RXData</a>;          <span class="comment">/*!&lt; Data to be transmitted */</span>
<a name="l00225"></a><a class="code" href="structt_u_d_p_request.html#a751d3070e77ef824ec375a233d8cde1a">00225</a>   ubyte <a class="code" href="structt_u_d_p_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>;                <span class="comment">/*!&lt; Amount of data to be transmitted */</span>
<a name="l00226"></a><a class="code" href="structt_u_d_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">00226</a>   ubyte <a class="code" href="structt_u_d_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a>;              <span class="comment">/*!&lt; result code: 0 if everything was fine, 1 if there was an error */</span>
<a name="l00227"></a>00227 } <a class="code" href="structt_u_d_p_request.html">tUDPRequest</a>;
<a name="l00228"></a>00228 
<a name="l00229"></a>00229 <span class="comment">// tSSIDInfo SSIDs[8];</span>
<a name="l00230"></a>00230 <span class="comment"></span>
<a name="l00231"></a>00231 <span class="comment">/**</span>
<a name="l00232"></a>00232 <span class="comment"> * Calculate the size of a string in an array.  Counts up to the NULL.</span>
<a name="l00233"></a>00233 <span class="comment"> * @param array the array to check the length of</span>
<a name="l00234"></a>00234 <span class="comment"> * @return length of the string in the array</span>
<a name="l00235"></a>00235 <span class="comment"> */</span>
<a name="l00236"></a><a class="code" href="group___h_r_w_b.html#gaa11c521e2287b090a4acda9f5d41b87b">00236</a> <span class="keywordtype">int</span> <a class="code" href="group___h_r_w_b.html#gaa11c521e2287b090a4acda9f5d41b87b">strsize</a>(<a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> &amp;array)
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a>); i++)
<a name="l00239"></a>00239   {
<a name="l00240"></a>00240     <span class="keywordflow">if</span>((ubyte)array[i] == 0)
<a name="l00241"></a>00241       <span class="keywordflow">return</span> i;
<a name="l00242"></a>00242   }
<a name="l00243"></a>00243   <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a>);
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 <span class="comment"></span>
<a name="l00247"></a>00247 <span class="comment">/**</span>
<a name="l00248"></a>00248 <span class="comment"> * Convert a string to a tIPaddr struct. This is an IPv4 address.</span>
<a name="l00249"></a>00249 <span class="comment"> * @param address string representation of the IPv4 address</span>
<a name="l00250"></a>00250 <span class="comment"> * @param addr tIPaddr struct to hold the IPv4 address</span>
<a name="l00251"></a>00251 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00252"></a>00252 <span class="comment"> */</span>
<a name="l00253"></a><a class="code" href="group___h_r_w_b.html#gadce6fb26dcb50c6a8048a320d6fa13ab">00253</a> <span class="keywordtype">void</span> <a class="code" href="group___h_r_w_b.html#gadce6fb26dcb50c6a8048a320d6fa13ab">stringToIp</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> address, <a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> &amp;addr)
<a name="l00254"></a>00254 {
<a name="l00255"></a>00255   <span class="keywordtype">string</span> octet;
<a name="l00256"></a>00256   <span class="keywordtype">string</span> copy;
<a name="l00257"></a>00257   <span class="keywordtype">int</span> index = 0;
<a name="l00258"></a>00258   memcpy(copy, address, 20);
<a name="l00259"></a>00259 
<a name="l00260"></a>00260   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 3; i++)
<a name="l00261"></a>00261   {
<a name="l00262"></a>00262     octet = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00263"></a>00263     index = <a class="code" href="group___n_x_t2_w_i_f_i.html#gac9623873538026c63a3f80d3f41a787f">StringFind</a>(copy, <span class="stringliteral">&quot;.&quot;</span>);
<a name="l00264"></a>00264     memcpy(octet, copy, index);
<a name="l00265"></a>00265     addr[i] = atoi(octet);
<a name="l00266"></a>00266     StringDelete(copy, 0, index+1);
<a name="l00267"></a>00267   }
<a name="l00268"></a>00268   addr[3] = atoi(copy);
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270 
<a name="l00271"></a>00271 <span class="comment"></span>
<a name="l00272"></a>00272 <span class="comment">/**</span>
<a name="l00273"></a>00273 <span class="comment"> * Perform a masked write, which allows you to select a single bit in a register.</span>
<a name="l00274"></a>00274 <span class="comment"> * @param link the port number</span>
<a name="l00275"></a>00275 <span class="comment"> * @param reg register to write to</span>
<a name="l00276"></a>00276 <span class="comment"> * @param data value to write to the register</span>
<a name="l00277"></a>00277 <span class="comment"> * @param mask to use when writing to the register</span>
<a name="l00278"></a>00278 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00279"></a>00279 <span class="comment"> */</span>
<a name="l00280"></a><a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">00280</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(tSensors link, <span class="keywordtype">int</span> reg, ubyte data, ubyte mask)
<a name="l00281"></a>00281 {
<a name="l00282"></a>00282   <span class="comment">// writeDebugStreamLine(&quot;writeRegMasked&quot;);</span>
<a name="l00283"></a>00283   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00284"></a>00284 
<a name="l00285"></a>00285   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[0] =  6;                  <span class="comment">//Message Size, here 7 Bytes</span>
<a name="l00286"></a>00286   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[1] =  <a class="code" href="group___h_r_w_b.html#ga548a056a3a942b82993ad2d3ebefb22f">HRWB_I2C_ADDR</a>;
<a name="l00287"></a>00287   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[2] =  <a class="code" href="group___h_r_w_b.html#ga48ef04ac1663530ad290365ddf158e2f">HRWB_MASKED_WRITE</a>;
<a name="l00288"></a>00288   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[3] =  (reg &gt;&gt; 8) &amp; 0xFF;  <span class="comment">//Read address register - Msb</span>
<a name="l00289"></a>00289   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[4] =  reg &amp; 0xFF;         <span class="comment">//Read address register - Lsb</span>
<a name="l00290"></a>00290   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[5] =  mask;               <span class="comment">//data</span>
<a name="l00291"></a>00291   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[6] =  data;               <span class="comment">//mask</span>
<a name="l00292"></a>00292 
<a name="l00293"></a>00293   <span class="keywordflow">return</span> <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>);
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 
<a name="l00296"></a>00296 <span class="comment"></span>
<a name="l00297"></a>00297 <span class="comment">/**</span>
<a name="l00298"></a>00298 <span class="comment"> * Write a single byte to a register</span>
<a name="l00299"></a>00299 <span class="comment"> * @param link the port number</span>
<a name="l00300"></a>00300 <span class="comment"> * @param reg register to write to</span>
<a name="l00301"></a>00301 <span class="comment"> * @param data value to write to the register</span>
<a name="l00302"></a>00302 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00303"></a>00303 <span class="comment"> */</span>
<a name="l00304"></a><a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">00304</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(tSensors link, <span class="keywordtype">int</span> reg, ubyte data)
<a name="l00305"></a>00305 {
<a name="l00306"></a>00306   <span class="comment">// writeDebugStreamLine(&quot;writeReg&quot;);</span>
<a name="l00307"></a>00307   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00308"></a>00308 
<a name="l00309"></a>00309   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[0] =  5;                  <span class="comment">//Message Size, here 7 Bytes</span>
<a name="l00310"></a>00310   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[1] =  <a class="code" href="group___h_r_w_b.html#ga548a056a3a942b82993ad2d3ebefb22f">HRWB_I2C_ADDR</a>;
<a name="l00311"></a>00311   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[2] =  <a class="code" href="group___h_r_w_b.html#ga6296663d4eb46220970fc210bcfe7ef8">HRWB_SIMPLE_WRITE</a>;
<a name="l00312"></a>00312   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[3] =  (reg &gt;&gt; 8) &amp; 0xFF;  <span class="comment">//Read address register - Msb</span>
<a name="l00313"></a>00313   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[4] =  reg &amp; 0xFF;         <span class="comment">//Read address register - Lsb</span>
<a name="l00314"></a>00314   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[5] =  data;                <span class="comment">//Msb SensorType Register</span>
<a name="l00315"></a>00315 
<a name="l00316"></a>00316   <span class="keywordflow">return</span> <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>);
<a name="l00317"></a>00317 }
<a name="l00318"></a>00318 
<a name="l00319"></a>00319 <span class="comment"></span>
<a name="l00320"></a>00320 <span class="comment">/**</span>
<a name="l00321"></a>00321 <span class="comment"> * Write data array to a register</span>
<a name="l00322"></a>00322 <span class="comment"> *</span>
<a name="l00323"></a>00323 <span class="comment"> * Note: this is an internal function and shouldn&#39;t be used directly</span>
<a name="l00324"></a>00324 <span class="comment"> * @param link the port number</span>
<a name="l00325"></a>00325 <span class="comment"> * @param reg register to write to</span>
<a name="l00326"></a>00326 <span class="comment"> * @param data value to write to the register</span>
<a name="l00327"></a>00327 <span class="comment"> * @param size amount of data to send</span>
<a name="l00328"></a>00328 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00329"></a>00329 <span class="comment"> */</span>
<a name="l00330"></a><a class="code" href="group___h_r_w_b.html#gaecaac1218bb1ce9dfc78179f77932b14">00330</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gaecaac1218bb1ce9dfc78179f77932b14">_HRWBwriteRegPrivate</a>(tSensors link, <span class="keywordtype">int</span> reg, <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> &amp;data, <span class="keywordtype">int</span> size)
<a name="l00331"></a>00331 {
<a name="l00332"></a>00332   <span class="keywordflow">if</span> (size &gt; 12)
<a name="l00333"></a>00333     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00334"></a>00334 
<a name="l00335"></a>00335   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00336"></a>00336 
<a name="l00337"></a>00337   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[0] =  4 + size;                  <span class="comment">//Message Size, here 7 Bytes</span>
<a name="l00338"></a>00338   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[1] =  <a class="code" href="group___h_r_w_b.html#ga548a056a3a942b82993ad2d3ebefb22f">HRWB_I2C_ADDR</a>;
<a name="l00339"></a>00339   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[2] =  <a class="code" href="group___h_r_w_b.html#ga6296663d4eb46220970fc210bcfe7ef8">HRWB_SIMPLE_WRITE</a>;
<a name="l00340"></a>00340   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[3] =  (reg &gt;&gt; 8) &amp; 0xFF;  <span class="comment">//Read address register - Msb</span>
<a name="l00341"></a>00341   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[4] =  reg &amp; 0xFF;         <span class="comment">//Read address register - Lsb</span>
<a name="l00342"></a>00342 
<a name="l00343"></a>00343   memcpy(&amp;<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[5], data, size);
<a name="l00344"></a>00344 
<a name="l00345"></a>00345   <span class="keywordflow">return</span> <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>);
<a name="l00346"></a>00346 }
<a name="l00347"></a>00347 
<a name="l00348"></a>00348 <span class="comment"></span>
<a name="l00349"></a>00349 <span class="comment">/**</span>
<a name="l00350"></a>00350 <span class="comment"> * Write a tByteArray struct to a register</span>
<a name="l00351"></a>00351 <span class="comment"> * @param link the port number</span>
<a name="l00352"></a>00352 <span class="comment"> * @param reg register to write to</span>
<a name="l00353"></a>00353 <span class="comment"> * @param data tByteArray to write to the register</span>
<a name="l00354"></a>00354 <span class="comment"> * @param size amount of data to send</span>
<a name="l00355"></a>00355 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00356"></a>00356 <span class="comment"> */</span>
<a name="l00357"></a><a class="code" href="group___h_r_w_b.html#ga8f68cccced86f31af75d76244f9b3c8b">00357</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(tSensors link, <span class="keywordtype">int</span> reg, <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> &amp;data, <span class="keywordtype">int</span> size)
<a name="l00358"></a>00358 {
<a name="l00359"></a>00359   <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> tmpBuff;
<a name="l00360"></a>00360   <span class="comment">// writeDebugStreamLine(&quot;writeReg tByteArray&quot;);</span>
<a name="l00361"></a>00361   <span class="keywordtype">int</span> bytesleft = size;
<a name="l00362"></a>00362   <span class="keywordtype">int</span> datalen = 0;
<a name="l00363"></a>00363 
<a name="l00364"></a>00364   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i =  0; i &lt; ((size/12) + 1); i++)
<a name="l00365"></a>00365         {
<a name="l00366"></a>00366           datalen = (bytesleft &gt; 12) ? 12 : bytesleft;
<a name="l00367"></a>00367           memset(tmpBuff, 0, <span class="keyword">sizeof</span>(tmpBuff));
<a name="l00368"></a>00368           memcpy(tmpBuff, &amp;data[i*12], datalen);
<a name="l00369"></a>00369 
<a name="l00370"></a>00370           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaecaac1218bb1ce9dfc78179f77932b14">_HRWBwriteRegPrivate</a>(link, reg + (i*12), tmpBuff, datalen))
<a name="l00371"></a>00371             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00372"></a>00372           bytesleft -= 12;
<a name="l00373"></a>00373         }
<a name="l00374"></a>00374         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376 
<a name="l00377"></a>00377 <span class="comment"></span>
<a name="l00378"></a>00378 <span class="comment">/**</span>
<a name="l00379"></a>00379 <span class="comment"> * Write a tHugeByteArray struct to a register</span>
<a name="l00380"></a>00380 <span class="comment"> * @param link the port number</span>
<a name="l00381"></a>00381 <span class="comment"> * @param reg register to write to</span>
<a name="l00382"></a>00382 <span class="comment"> * @param data tHugeByteArray to write to the register</span>
<a name="l00383"></a>00383 <span class="comment"> * @param size amount of data to send</span>
<a name="l00384"></a>00384 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00385"></a>00385 <span class="comment"> */</span>
<a name="l00386"></a>00386 <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(tSensors link, <span class="keywordtype">int</span> reg, <a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a> &amp;data, <span class="keywordtype">int</span> size)
<a name="l00387"></a>00387 {
<a name="l00388"></a>00388   <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> tmpBuff;
<a name="l00389"></a>00389   <span class="keywordtype">int</span> bytesleft = size;
<a name="l00390"></a>00390   <span class="keywordtype">int</span> datalen = 0;
<a name="l00391"></a>00391 
<a name="l00392"></a>00392   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i =  0; i &lt; ((size/12) + 1); i++)
<a name="l00393"></a>00393         {
<a name="l00394"></a>00394           datalen = (bytesleft &gt; 12) ? 12 : bytesleft;
<a name="l00395"></a>00395           memset(tmpBuff, 0, <span class="keyword">sizeof</span>(tmpBuff));
<a name="l00396"></a>00396           memcpy(tmpBuff, &amp;data[i*12], datalen);
<a name="l00397"></a>00397 
<a name="l00398"></a>00398           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaecaac1218bb1ce9dfc78179f77932b14">_HRWBwriteRegPrivate</a>(link, reg + (i*12), tmpBuff, datalen))
<a name="l00399"></a>00399             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00400"></a>00400           bytesleft -= 12;
<a name="l00401"></a>00401         }
<a name="l00402"></a>00402         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00403"></a>00403 }
<a name="l00404"></a>00404 
<a name="l00405"></a>00405 <span class="comment"></span>
<a name="l00406"></a>00406 <span class="comment">/**</span>
<a name="l00407"></a>00407 <span class="comment"> * Write a tBigByteArray struct to a register</span>
<a name="l00408"></a>00408 <span class="comment"> * @param link the port number</span>
<a name="l00409"></a>00409 <span class="comment"> * @param reg register to write to</span>
<a name="l00410"></a>00410 <span class="comment"> * @param data tBigByteArray to write to the register</span>
<a name="l00411"></a>00411 <span class="comment"> * @param size amount of data to send</span>
<a name="l00412"></a>00412 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00413"></a>00413 <span class="comment"> */</span>
<a name="l00414"></a>00414 <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(tSensors link, <span class="keywordtype">int</span> reg, <a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a> &amp;data, <span class="keywordtype">int</span> size)
<a name="l00415"></a>00415 {
<a name="l00416"></a>00416   <a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a> tmpBuff;
<a name="l00417"></a>00417   <span class="keywordtype">int</span> bytesleft = size;
<a name="l00418"></a>00418   <span class="keywordtype">int</span> datalen = 0;
<a name="l00419"></a>00419 
<a name="l00420"></a>00420   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i =  0; i &lt; ((size/12) + 1); i++)
<a name="l00421"></a>00421         {
<a name="l00422"></a>00422           datalen = (bytesleft &gt; 12) ? 12 : bytesleft;
<a name="l00423"></a>00423           memset(tmpBuff, 0, <span class="keyword">sizeof</span>(tmpBuff));
<a name="l00424"></a>00424           memcpy(tmpBuff, &amp;data[i*12], datalen);
<a name="l00425"></a>00425 
<a name="l00426"></a>00426           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaecaac1218bb1ce9dfc78179f77932b14">_HRWBwriteRegPrivate</a>(link, reg + (i*12), tmpBuff, datalen))
<a name="l00427"></a>00427             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00428"></a>00428           bytesleft -= 12;
<a name="l00429"></a>00429         }
<a name="l00430"></a>00430         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 
<a name="l00433"></a>00433 <span class="comment"></span>
<a name="l00434"></a>00434 <span class="comment">/**</span>
<a name="l00435"></a>00435 <span class="comment"> * Read a register.  Data read is stored in HRWB_I2CReply</span>
<a name="l00436"></a>00436 <span class="comment"> * @param link the port number</span>
<a name="l00437"></a>00437 <span class="comment"> * @param reg register to read</span>
<a name="l00438"></a>00438 <span class="comment"> * @param size amount of data to read</span>
<a name="l00439"></a>00439 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00440"></a>00440 <span class="comment"> */</span>
<a name="l00441"></a><a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">00441</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(tSensors link, <span class="keywordtype">int</span> reg, <span class="keywordtype">int</span> size)
<a name="l00442"></a>00442 {
<a name="l00443"></a>00443   <span class="comment">// writeDebugStreamLine(&quot;readReg&quot;);</span>
<a name="l00444"></a>00444   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00445"></a>00445 
<a name="l00446"></a>00446   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[0] =  7;                  <span class="comment">//Message Size, here 7 Bytes</span>
<a name="l00447"></a>00447   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[1] =  <a class="code" href="group___h_r_w_b.html#ga548a056a3a942b82993ad2d3ebefb22f">HRWB_I2C_ADDR</a>;
<a name="l00448"></a>00448   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[2] =  <a class="code" href="group___h_r_w_b.html#ga6296663d4eb46220970fc210bcfe7ef8">HRWB_SIMPLE_WRITE</a>;
<a name="l00449"></a>00449   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[3] =  0x01;               <span class="comment">//Read address register - Msb</span>
<a name="l00450"></a>00450   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[4] =  0x00;               <span class="comment">//Read address register - Lsb</span>
<a name="l00451"></a>00451   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[5] =  (reg &gt;&gt; 8) &amp; 0xFF;  <span class="comment">//Msb SensorType Register</span>
<a name="l00452"></a>00452   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[6] =  reg &amp; 0xFF;         <span class="comment">//Lsb SensorType Register</span>
<a name="l00453"></a>00453   <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>[7] =  size &amp; 0xFF;        <span class="comment">//Size of the returned message</span>
<a name="l00454"></a>00454 
<a name="l00455"></a>00455   <span class="keywordflow">return</span> <a class="code" href="group__common.html#gad02e06f83b264ee6fc7df41eb4712080">writeI2C</a>(link, <a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>, size);
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457 
<a name="l00458"></a>00458 <span class="comment"></span>
<a name="l00459"></a>00459 <span class="comment">/**</span>
<a name="l00460"></a>00460 <span class="comment"> * Read a register.  Data read is stored in HRWB_HugeArray</span>
<a name="l00461"></a>00461 <span class="comment"> * @param link the port number</span>
<a name="l00462"></a>00462 <span class="comment"> * @param reg register to read</span>
<a name="l00463"></a>00463 <span class="comment"> * @param size amount of data to read</span>
<a name="l00464"></a>00464 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00465"></a>00465 <span class="comment"> */</span>
<a name="l00466"></a><a class="code" href="group___h_r_w_b.html#gaf2d5e1b8236c9b9fb2cf8cea26d48e5f">00466</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gaf2d5e1b8236c9b9fb2cf8cea26d48e5f">HRWBreadBigReg</a>(tSensors link, <span class="keywordtype">int</span> reg, <span class="keywordtype">int</span> size)
<a name="l00467"></a>00467 {
<a name="l00468"></a>00468   <span class="comment">// writeDebugStreamLine(&quot;readBigReg&quot;);</span>
<a name="l00469"></a>00469   <span class="keywordtype">int</span> bytesleft = size;
<a name="l00470"></a>00470   <span class="keywordtype">int</span> requestlen = 0;
<a name="l00471"></a>00471   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00472"></a>00472   memset(<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>));
<a name="l00473"></a>00473 
<a name="l00474"></a>00474   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i =  0; i &lt; ((size/16) + 1); i++)
<a name="l00475"></a>00475         {
<a name="l00476"></a>00476           requestlen = (bytesleft &gt; 16) ? 16 : bytesleft;
<a name="l00477"></a>00477           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, reg + (i*16), requestlen))
<a name="l00478"></a>00478             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00479"></a>00479           memcpy(&amp;<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>[16 * i], <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>, requestlen);
<a name="l00480"></a>00480           bytesleft -= 16;
<a name="l00481"></a>00481           wait1Msec(10);
<a name="l00482"></a>00482         }
<a name="l00483"></a>00483         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00484"></a>00484 }
<a name="l00485"></a>00485 
<a name="l00486"></a>00486 <span class="comment"></span>
<a name="l00487"></a>00487 <span class="comment">/**</span>
<a name="l00488"></a>00488 <span class="comment"> * Read the HTTP result code of the last HTTP transaction.</span>
<a name="l00489"></a>00489 <span class="comment"> * @param link the port number</span>
<a name="l00490"></a>00490 <span class="comment"> * @return the HTTP result code</span>
<a name="l00491"></a>00491 <span class="comment"> */</span>
<a name="l00492"></a><a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">00492</a> <span class="keywordtype">int</span> <a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">HRWBreadHTTPCode</a>(tSensors link)
<a name="l00493"></a>00493 {
<a name="l00494"></a>00494   <span class="keywordtype">string</span> tmpResultCode;
<a name="l00495"></a>00495   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(WifiBlockPort, <a class="code" href="group___h_r_w_b.html#ga2afbd442d6e578dfd2d5fde12c43e713">HRWB_HTTP_RESULT_CODE</a>, 3);
<a name="l00496"></a>00496   <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[3] = 0;
<a name="l00497"></a>00497   memcpy(tmpResultCode, <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>, 4);
<a name="l00498"></a>00498   <span class="keywordflow">return</span> atoi(tmpResultCode);
<a name="l00499"></a>00499 }
<a name="l00500"></a>00500 
<a name="l00501"></a>00501 <span class="comment"></span>
<a name="l00502"></a>00502 <span class="comment">/**</span>
<a name="l00503"></a>00503 <span class="comment"> * Reset the WiFiBlock.</span>
<a name="l00504"></a>00504 <span class="comment"> * @param link the port number</span>
<a name="l00505"></a>00505 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00506"></a>00506 <span class="comment"> */</span>
<a name="l00507"></a><a class="code" href="group___h_r_w_b.html#ga08f2d85c6d42dcd3bdcc12330b6875e6">00507</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga08f2d85c6d42dcd3bdcc12330b6875e6">HRWBresetWifiBlock</a>(tSensors link)
<a name="l00508"></a>00508 {
<a name="l00509"></a>00509   <span class="comment">// writeDebugStreamLine(&quot;resetWifiBlock&quot;);</span>
<a name="l00510"></a>00510   <span class="keywordflow">return</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(WifiBlockPort, <a class="code" href="group___h_r_w_b.html#gaab85d73aba3db566b7ab538a3f6ab81b">HRWB_RESET</a>, 1, <a class="code" href="group___h_r_w_b.html#ga3834577d8f0f4599a7d108b2e15fe365">HRWB_RESET_WIFIBLOCK</a>);
<a name="l00511"></a>00511 }
<a name="l00512"></a>00512 
<a name="l00513"></a>00513 <span class="comment"></span>
<a name="l00514"></a>00514 <span class="comment">/**</span>
<a name="l00515"></a>00515 <span class="comment"> * Read the current voltage level</span>
<a name="l00516"></a>00516 <span class="comment"> * @param link the port number</span>
<a name="l00517"></a>00517 <span class="comment"> * @return current voltage level</span>
<a name="l00518"></a>00518 <span class="comment"> */</span>
<a name="l00519"></a><a class="code" href="group___h_r_w_b.html#ga0c5dd26d638bcf2871d842aa56f3eb90">00519</a> <span class="keywordtype">float</span> <a class="code" href="group___h_r_w_b.html#ga0c5dd26d638bcf2871d842aa56f3eb90">HRWBreadBatt</a>(tSensors link)
<a name="l00520"></a>00520 {
<a name="l00521"></a>00521   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga5c5be32eddde62186fae481b78f364ea">HRWB_BATTLVL</a>, 1);
<a name="l00522"></a>00522   <span class="keywordflow">return</span> (<span class="keywordtype">float</span>)<a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0]/10.0;
<a name="l00523"></a>00523 
<a name="l00524"></a>00524 }
<a name="l00525"></a>00525 
<a name="l00526"></a>00526 <span class="comment"></span>
<a name="l00527"></a>00527 <span class="comment">/**</span>
<a name="l00528"></a>00528 <span class="comment"> * Read the type of sensor. Should be WIFI, unless there&#39;s</span>
<a name="l00529"></a>00529 <span class="comment"> * something really freaky going on</span>
<a name="l00530"></a>00530 <span class="comment"> * @param link the port number</span>
<a name="l00531"></a>00531 <span class="comment"> * @param sType string to hold the sensor type string.</span>
<a name="l00532"></a>00532 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00533"></a>00533 <span class="comment"> */</span>
<a name="l00534"></a><a class="code" href="group___h_r_w_b.html#ga7226503ddb002b387b242a30e1b6329e">00534</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga7226503ddb002b387b242a30e1b6329e">HRWBreadSensorType</a> (tSensors link, <span class="keywordtype">string</span> &amp;sType)
<a name="l00535"></a>00535 {
<a name="l00536"></a>00536   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga04ac32bb96f353ff11dd4fc2d068c113">HRWB_SENSORTYPE</a>, 4))
<a name="l00537"></a>00537     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00538"></a>00538 
<a name="l00539"></a>00539   StringFromChars(sType, &amp;<a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>);
<a name="l00540"></a>00540 
<a name="l00541"></a>00541   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00542"></a>00542 }
<a name="l00543"></a>00543 
<a name="l00544"></a>00544 <span class="comment"></span>
<a name="l00545"></a>00545 <span class="comment">/**</span>
<a name="l00546"></a>00546 <span class="comment"> * Enable the WiFi</span>
<a name="l00547"></a>00547 <span class="comment"> * @param link the port number</span>
<a name="l00548"></a>00548 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00549"></a>00549 <span class="comment"> */</span>
<a name="l00550"></a><a class="code" href="group___h_r_w_b.html#ga43c5120747744edf0bcb6a3090a5fe92">00550</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga43c5120747744edf0bcb6a3090a5fe92">HRWBenableWifi</a>(tSensors link)
<a name="l00551"></a>00551 {
<a name="l00552"></a>00552   <span class="comment">//writeDebugStreamLine(&quot;enableWifi&quot;);</span>
<a name="l00553"></a>00553   <span class="keywordflow">return</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, 0x01, <a class="code" href="group___h_r_w_b.html#ga9abd1e799800f57443b81d2940d27ede">HRWB_WIFI_STATUS_ENABLE</a>);
<a name="l00554"></a>00554 }
<a name="l00555"></a>00555 
<a name="l00556"></a>00556 <span class="comment"></span>
<a name="l00557"></a>00557 <span class="comment">/**</span>
<a name="l00558"></a>00558 <span class="comment"> * Disable the WiFi</span>
<a name="l00559"></a>00559 <span class="comment"> * @param link the port number</span>
<a name="l00560"></a>00560 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00561"></a>00561 <span class="comment"> */</span>
<a name="l00562"></a><a class="code" href="group___h_r_w_b.html#gaf30b3421749620a98d8e9a6854e912f8">00562</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gaf30b3421749620a98d8e9a6854e912f8">HRWBdisableWifi</a>(tSensors link)
<a name="l00563"></a>00563 {
<a name="l00564"></a>00564   <span class="comment">//writeDebugStreamLine(&quot;disableWifi&quot;);</span>
<a name="l00565"></a>00565   <span class="keywordflow">return</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, 0x00, <a class="code" href="group___h_r_w_b.html#ga9abd1e799800f57443b81d2940d27ede">HRWB_WIFI_STATUS_ENABLE</a>);
<a name="l00566"></a>00566 }
<a name="l00567"></a>00567 
<a name="l00568"></a>00568 <span class="comment"></span>
<a name="l00569"></a>00569 <span class="comment">/**</span>
<a name="l00570"></a>00570 <span class="comment"> * Save the current network configuration</span>
<a name="l00571"></a>00571 <span class="comment"> * @param link the port number</span>
<a name="l00572"></a>00572 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00573"></a>00573 <span class="comment"> */</span>
<a name="l00574"></a><a class="code" href="group___h_r_w_b.html#ga6dc9b4bc962ad5295684d904a2877c1a">00574</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga6dc9b4bc962ad5295684d904a2877c1a">HRWBsaveConfig</a>(tSensors link)
<a name="l00575"></a>00575 {
<a name="l00576"></a>00576   <span class="comment">//writeDebugStreamLine(&quot;saveConfig&quot;);</span>
<a name="l00577"></a>00577   <span class="keywordflow">return</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, 0x02, <a class="code" href="group___h_r_w_b.html#gaaf0701da2df31629a835b2b1dca36e4f">HRWB_WIFI_STATUS_SAVE_CONF</a>);
<a name="l00578"></a>00578 }
<a name="l00579"></a>00579 
<a name="l00580"></a>00580 <span class="comment"></span>
<a name="l00581"></a>00581 <span class="comment">/**</span>
<a name="l00582"></a>00582 <span class="comment"> * Erase the current network configuration\n</span>
<a name="l00583"></a>00583 <span class="comment"> * Use in combination with HRWBresetWifiBlock()</span>
<a name="l00584"></a>00584 <span class="comment"> * to start with a clean configuration</span>
<a name="l00585"></a>00585 <span class="comment"> * @param link the port number</span>
<a name="l00586"></a>00586 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00587"></a>00587 <span class="comment"> */</span>
<a name="l00588"></a><a class="code" href="group___h_r_w_b.html#gad839b98bd40c7f22564d5777a6be1f0e">00588</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gad839b98bd40c7f22564d5777a6be1f0e">HRWBeraseConfig</a>(tSensors link)
<a name="l00589"></a>00589 {
<a name="l00590"></a>00590   <span class="comment">//writeDebugStreamLine(&quot;eraseConfig&quot;);</span>
<a name="l00591"></a>00591   <span class="keywordflow">return</span> <a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, 0x80, <a class="code" href="group___h_r_w_b.html#ga248b1fde63ff7b75580d4b29217bb074">HRWB_WIFI_STATUS_DEL_CONF</a>);
<a name="l00592"></a>00592 }
<a name="l00593"></a>00593 
<a name="l00594"></a>00594 
<a name="l00595"></a>00595 <span class="comment">/*</span>
<a name="l00596"></a>00596 <span class="comment">bool HRWBscanChannel(tSensors link, ubyte channel) {</span>
<a name="l00597"></a>00597 <span class="comment">  string tmpString;</span>
<a name="l00598"></a>00598 <span class="comment">  char tmpCharArray[20];</span>
<a name="l00599"></a>00599 <span class="comment">  int SSIDcount = 0;</span>
<a name="l00600"></a>00600 <span class="comment">  memset(HRWB_I2CRequest, 0, sizeof(tByteArray));</span>
<a name="l00601"></a>00601 <span class="comment"></span>
<a name="l00602"></a>00602 <span class="comment">  writeDebugStreamLine(&quot;channel: %d&quot;, channel);</span>
<a name="l00603"></a>00603 <span class="comment">  if (!HRWBwriteReg(link, HRWB_WIFI_SCANSEL, channel))</span>
<a name="l00604"></a>00604 <span class="comment">    return false;</span>
<a name="l00605"></a>00605 <span class="comment"></span>
<a name="l00606"></a>00606 <span class="comment">  // Start scan</span>
<a name="l00607"></a>00607 <span class="comment">  HRWB_I2CRequest[0] =  6;                  //Message Size, here 7 Bytes</span>
<a name="l00608"></a>00608 <span class="comment">  HRWB_I2CRequest[1] =  HRWB_I2C_ADDR;</span>
<a name="l00609"></a>00609 <span class="comment">  HRWB_I2CRequest[2] =  HRWB_MASKED_WRITE;</span>
<a name="l00610"></a>00610 <span class="comment">  HRWB_I2CRequest[3] =  0x02;               //Read address register - Msb</span>
<a name="l00611"></a>00611 <span class="comment">  HRWB_I2CRequest[4] =  0x00;               //Read address register - Lsb</span>
<a name="l00612"></a>00612 <span class="comment">  HRWB_I2CRequest[5] =  0x04;               //Msb SensorType Register</span>
<a name="l00613"></a>00613 <span class="comment">  HRWB_I2CRequest[6] =  0x04;               //Lsb SensorType Register</span>
<a name="l00614"></a>00614 <span class="comment"></span>
<a name="l00615"></a>00615 <span class="comment">  if (!writeI2C(link, HRWB_I2CRequest, 0))</span>
<a name="l00616"></a>00616 <span class="comment">    return false;</span>
<a name="l00617"></a>00617 <span class="comment"></span>
<a name="l00618"></a>00618 <span class="comment">  // Wait for scan to be done</span>
<a name="l00619"></a>00619 <span class="comment">  while (true) {</span>
<a name="l00620"></a>00620 <span class="comment">          HRWBreadReg(link, HRWB_WIFI_STATUS, 1);</span>
<a name="l00621"></a>00621 <span class="comment">          if ((HRWB_I2CReply[0] &amp; 0x08) == 0x08)</span>
<a name="l00622"></a>00622 <span class="comment">            break;</span>
<a name="l00623"></a>00623 <span class="comment">          wait1Msec(100);</span>
<a name="l00624"></a>00624 <span class="comment">        }</span>
<a name="l00625"></a>00625 <span class="comment"></span>
<a name="l00626"></a>00626 <span class="comment">  HRWBwriteReg(link, HRWB_WIFI_SCANSEL, channel);</span>
<a name="l00627"></a>00627 <span class="comment">  wait1Msec(10);</span>
<a name="l00628"></a>00628 <span class="comment">  HRWBreadBigReg(link, HRWB_WIFI_SCANSSID, 64);</span>
<a name="l00629"></a>00629 <span class="comment">  StringFromChars(tmpString, HRWB_HugeArray);</span>
<a name="l00630"></a>00630 <span class="comment">  writeDebugStream(&quot;Found [%d]: &quot;, channel);</span>
<a name="l00631"></a>00631 <span class="comment">  writeDebugStreamLine(tmpString);</span>
<a name="l00632"></a>00632 <span class="comment">  return true;</span>
<a name="l00633"></a>00633 <span class="comment">}</span>
<a name="l00634"></a>00634 <span class="comment"></span>
<a name="l00635"></a>00635 <span class="comment"></span>
<a name="l00636"></a>00636 <span class="comment"></span>
<a name="l00637"></a>00637 <span class="comment"></span>
<a name="l00638"></a>00638 <span class="comment">bool HRWBscanWifi(tSensors link)</span>
<a name="l00639"></a>00639 <span class="comment">{</span>
<a name="l00640"></a>00640 <span class="comment">  char tmpCharArray[20];</span>
<a name="l00641"></a>00641 <span class="comment">  int SSIDcount = 0;</span>
<a name="l00642"></a>00642 <span class="comment">  memset(HRWB_I2CRequest, 0, sizeof(tByteArray));</span>
<a name="l00643"></a>00643 <span class="comment"></span>
<a name="l00644"></a>00644 <span class="comment">  if (!HRWBwriteRegMasked(link, HRWB_WIFI_STATUS, HRWB_WIFI_STATUS_START_SCAN, HRWB_WIFI_STATUS_START_SCAN))</span>
<a name="l00645"></a>00645 <span class="comment">    return false;</span>
<a name="l00646"></a>00646 <span class="comment"></span>
<a name="l00647"></a>00647 <span class="comment">  // Wait for scan to be done</span>
<a name="l00648"></a>00648 <span class="comment">  while (true) {</span>
<a name="l00649"></a>00649 <span class="comment">          HRWBreadReg(link, HRWB_WIFI_STATUS, 1);</span>
<a name="l00650"></a>00650 <span class="comment">          if ((HRWB_I2CReply[0] &amp;  HRWB_WIFI_STATUS_SCAN_DONE) == HRWB_WIFI_STATUS_SCAN_DONE)</span>
<a name="l00651"></a>00651 <span class="comment">            break;</span>
<a name="l00652"></a>00652 <span class="comment">          wait1Msec(100);</span>
<a name="l00653"></a>00653 <span class="comment">        }</span>
<a name="l00654"></a>00654 <span class="comment"></span>
<a name="l00655"></a>00655 <span class="comment">        // Fetch number of SSIDs found.</span>
<a name="l00656"></a>00656 <span class="comment">  HRWBreadReg(link, HRWB_WIFI_SCANRESULT, 1);</span>
<a name="l00657"></a>00657 <span class="comment">  SSIDcount = HRWB_I2CReply[0];</span>
<a name="l00658"></a>00658 <span class="comment">  writeDebugStreamLine(&quot;SSID count: %d&quot;, SSIDcount);</span>
<a name="l00659"></a>00659 <span class="comment">  if (SSIDcount == 0)</span>
<a name="l00660"></a>00660 <span class="comment">    return false;</span>
<a name="l00661"></a>00661 <span class="comment"></span>
<a name="l00662"></a>00662 <span class="comment">  writeDebugStreamLine(&quot;count: %d&quot;, SSIDcount);</span>
<a name="l00663"></a>00663 <span class="comment">  for (int i = 0; i &lt; SSIDcount; i++) {</span>
<a name="l00664"></a>00664 <span class="comment">    if (!HRWBscanChannel(link, i))</span>
<a name="l00665"></a>00665 <span class="comment">      return false;</span>
<a name="l00666"></a>00666 <span class="comment">    wait1Msec(10);</span>
<a name="l00667"></a>00667 <span class="comment">  }</span>
<a name="l00668"></a>00668 <span class="comment">  return true;</span>
<a name="l00669"></a>00669 <span class="comment"></span>
<a name="l00670"></a>00670 <span class="comment"></span>
<a name="l00671"></a>00671 <span class="comment">}</span>
<a name="l00672"></a>00672 <span class="comment">*/</span>
<a name="l00673"></a>00673 
<a name="l00674"></a>00674 <span class="comment"></span>
<a name="l00675"></a>00675 <span class="comment">/**</span>
<a name="l00676"></a>00676 <span class="comment"> * Configure the IP and WiFi settings</span>
<a name="l00677"></a>00677 <span class="comment"> * @param link the port number</span>
<a name="l00678"></a>00678 <span class="comment"> * @param netInfo tNetworkInfo struct containing network connection parameters</span>
<a name="l00679"></a>00679 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00680"></a>00680 <span class="comment"> */</span>
<a name="l00681"></a><a class="code" href="group___h_r_w_b.html#ga5eccf46af5670923b91097a1b84db016">00681</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga5eccf46af5670923b91097a1b84db016">HRWBconfigNetwork</a>(tSensors link, <a class="code" href="structt_network_info.html">tNetworkInfo</a> &amp;netInfo) {
<a name="l00682"></a>00682   <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
<a name="l00683"></a>00683   ubyte status;
<a name="l00684"></a>00684   memset(<a class="code" href="group___h_r_w_b.html#gabaa150f1d072bb39a19e2513f56bb6aa">HRWB_I2CRequest</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#gaa172ef131853460e5b9f5c6db81d30f4">tByteArray</a>));
<a name="l00685"></a>00685 
<a name="l00686"></a>00686   <span class="comment">// switch off the wifi</span>
<a name="l00687"></a>00687   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf30b3421749620a98d8e9a6854e912f8">HRWBdisableWifi</a>(link))
<a name="l00688"></a>00688     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00689"></a>00689 
<a name="l00690"></a>00690   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gad839b98bd40c7f22564d5777a6be1f0e">HRWBeraseConfig</a>(link))
<a name="l00691"></a>00691     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00692"></a>00692   wait1Msec(100);
<a name="l00693"></a>00693 
<a name="l00694"></a>00694   PlaySound(soundBlip);
<a name="l00695"></a>00695   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, netInfo.<a class="code" href="structt_network_info.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00696"></a>00696   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaf8cc035c9e680217d2bf57d5cd085c83">HRWB_WIFI_IP_ADDR</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>)))
<a name="l00697"></a>00697     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00698"></a>00698 
<a name="l00699"></a>00699         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, netInfo.<a class="code" href="structt_network_info.html#a6b6ec939233a56041fceaf9865d0e171">netmask</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00700"></a>00700         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga1d2d9ca4db96d5ab508d296d8e28eff7">HRWB_WIFI_IP_MASK</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>)))
<a name="l00701"></a>00701           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00702"></a>00702 
<a name="l00703"></a>00703         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, netInfo.<a class="code" href="structt_network_info.html#aff136b7050438924899191b52a061988">gateway</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00704"></a>00704         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga168bdb2de73c0a907878eb46df0e356a">HRWB_WIFI_IP_GATEWAY</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>)))
<a name="l00705"></a>00705           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00706"></a>00706 
<a name="l00707"></a>00707         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga127f77f0205c98d8855f6893dee444b6">HRWB_WIFI_SECURITY_TYPE</a>, netInfo.<a class="code" href="structt_network_info.html#aebfb3beb0bbd0f126f1c807e44431656">wifi_type</a>))
<a name="l00708"></a>00708           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00709"></a>00709 
<a name="l00710"></a>00710         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, netInfo.<a class="code" href="structt_network_info.html#a3f000c56bd8458cbf6b9cc3c76685a2c">wifi_ssid</a>, strlen(netInfo.<a class="code" href="structt_network_info.html#a3f000c56bd8458cbf6b9cc3c76685a2c">wifi_ssid</a>) + 1);
<a name="l00711"></a>00711         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaf0a94416246056eef2a340fd0bb040b0">HRWB_WIFI_SSID</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, strlen(netInfo.<a class="code" href="structt_network_info.html#a3f000c56bd8458cbf6b9cc3c76685a2c">wifi_ssid</a>) + 1))
<a name="l00712"></a>00712           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00713"></a>00713 
<a name="l00714"></a>00714   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, netInfo.<a class="code" href="structt_network_info.html#adbc92e636f928aee80429e36e717a3c5">wifi_pass</a>, strlen(netInfo.<a class="code" href="structt_network_info.html#adbc92e636f928aee80429e36e717a3c5">wifi_pass</a>) + 1);
<a name="l00715"></a>00715         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga29f211ff2e662b45dc09981e01cf3bdc">HRWB_WIFI_SECURITY_KEY</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, strlen(netInfo.<a class="code" href="structt_network_info.html#adbc92e636f928aee80429e36e717a3c5">wifi_pass</a>) + 1))
<a name="l00716"></a>00716           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00717"></a>00717 
<a name="l00718"></a>00718         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, <a class="code" href="group___h_r_w_b.html#ga3eb43fd6520957a65960861e6687c4cf">HRWB_WIFI_STATUS_RECONN</a>, <a class="code" href="group___h_r_w_b.html#ga3eb43fd6520957a65960861e6687c4cf">HRWB_WIFI_STATUS_RECONN</a>))
<a name="l00719"></a>00719           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00720"></a>00720 
<a name="l00721"></a>00721         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga6dc9b4bc962ad5295684d904a2877c1a">HRWBsaveConfig</a>(link))
<a name="l00722"></a>00722           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00723"></a>00723 
<a name="l00724"></a>00724         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga43c5120747744edf0bcb6a3090a5fe92">HRWBenableWifi</a>(link))
<a name="l00725"></a>00725           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00726"></a>00726 
<a name="l00727"></a>00727         <span class="keywordflow">while</span>(!done) {
<a name="l00728"></a>00728           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga41a3dcfc1d6f639dfe60bfd53ae90a73">HRWB_WIFI_STATUS</a>, 1))
<a name="l00729"></a>00729             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00730"></a>00730           status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00731"></a>00731 
<a name="l00732"></a>00732           <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga7fcc152ffca25463e0d1942e5923f634">HRWB_WIFI_STATUS_CONN_STAT</a>) == HRWB_WIFI_STATUS_CONN_STAT)
<a name="l00733"></a>00733           {
<a name="l00734"></a>00734             done = <span class="keyword">true</span>;
<a name="l00735"></a>00735           }
<a name="l00736"></a>00736           wait1Msec(100);
<a name="l00737"></a>00737         }
<a name="l00738"></a>00738 
<a name="l00739"></a>00739   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00740"></a>00740 }
<a name="l00741"></a>00741 
<a name="l00742"></a>00742 <span class="comment"></span>
<a name="l00743"></a>00743 <span class="comment">/**</span>
<a name="l00744"></a>00744 <span class="comment"> * Perform a HTTP GET transaction</span>
<a name="l00745"></a>00745 <span class="comment"> * @param link the port number</span>
<a name="l00746"></a>00746 <span class="comment"> * @param getrequest tGetRequest struct containing transaction parameters</span>
<a name="l00747"></a>00747 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00748"></a>00748 <span class="comment"> */</span>
<a name="l00749"></a><a class="code" href="group___h_r_w_b.html#ga6c0c2adf4af3e1dbde6f807745cbe82f">00749</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga6c0c2adf4af3e1dbde6f807745cbe82f">HRWBdoGET</a>(tSensors link, <a class="code" href="structt_get_request.html">tGetRequest</a> &amp;getrequest) {
<a name="l00750"></a>00750   ubyte status = 0;
<a name="l00751"></a>00751   <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
<a name="l00752"></a>00752   ubyte tmpPort[2];
<a name="l00753"></a>00753 
<a name="l00754"></a>00754   tmpPort[0] = (getrequest.<a class="code" href="structt_get_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 8) &amp; 0xFF;
<a name="l00755"></a>00755   tmpPort[1] = (getrequest.<a class="code" href="structt_get_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 0) &amp; 0xFF;
<a name="l00756"></a>00756 
<a name="l00757"></a>00757   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga4bd26a67c966bd8b5254d5fcf156725e">HRWB_GET_STATUS</a>, 1);
<a name="l00758"></a>00758   status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00759"></a>00759 
<a name="l00760"></a>00760   <span class="keywordflow">if</span> (status &amp; <a class="code" href="group___h_r_w_b.html#ga81cee7f8ba8308eccc51b9fe8773254f">HRWB_GET_STATUS_READY</a> != <a class="code" href="group___h_r_w_b.html#ga81cee7f8ba8308eccc51b9fe8773254f">HRWB_GET_STATUS_READY</a>)
<a name="l00761"></a>00761   {
<a name="l00762"></a>00762     writeDebugStreamLine(<span class="stringliteral">&quot;NOT READY&quot;</span>);
<a name="l00763"></a>00763     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00764"></a>00764   }
<a name="l00765"></a>00765 
<a name="l00766"></a>00766         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, getrequest.<a class="code" href="structt_get_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00767"></a>00767         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gad10bd1972de60eb5e0aef3af95a8183d">HRWB_GET_IP_ADDR</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>)))
<a name="l00768"></a>00768           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00769"></a>00769 
<a name="l00770"></a>00770   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tmpPort, 2);
<a name="l00771"></a>00771         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaf9311e92f8f5cb0e9355bd91545bc995">HRWB_GET_PORT</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 2))
<a name="l00772"></a>00772           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00773"></a>00773 
<a name="l00774"></a>00774         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga2694632bffe558b5159aa0b4dfa187bc">HRWB_GET_URL</a>, (<a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a>)getrequest.<a class="code" href="structt_get_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>, <a class="code" href="group___h_r_w_b.html#gaa11c521e2287b090a4acda9f5d41b87b">strsize</a>(getrequest.<a class="code" href="structt_get_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>) + 1))
<a name="l00775"></a>00775           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00776"></a>00776 
<a name="l00777"></a>00777         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga4bd26a67c966bd8b5254d5fcf156725e">HRWB_GET_STATUS</a>, <a class="code" href="group___h_r_w_b.html#gac35856e738d91770f8110df0572b7b43">HRWB_GET_STATUS_SEND_REQ</a>, <a class="code" href="group___h_r_w_b.html#gac35856e738d91770f8110df0572b7b43">HRWB_GET_STATUS_SEND_REQ</a>))
<a name="l00778"></a>00778           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00779"></a>00779 
<a name="l00780"></a>00780         <span class="keywordflow">while</span>(!done) {
<a name="l00781"></a>00781           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga4bd26a67c966bd8b5254d5fcf156725e">HRWB_GET_STATUS</a>, 1))
<a name="l00782"></a>00782             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00783"></a>00783 
<a name="l00784"></a>00784           status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00785"></a>00785 
<a name="l00786"></a>00786           <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga96cf5e7095b5a373a924ab76074f4936">HRWB_GET_STATUS_REQ_ERROR</a>) == HRWB_GET_STATUS_REQ_ERROR)
<a name="l00787"></a>00787           {
<a name="l00788"></a>00788             <span class="comment">//writeDebugStreamLine(&quot;ERROR GET: %d&quot;, status);</span>
<a name="l00789"></a>00789             getrequest.<a class="code" href="structt_get_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = <a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">HRWBreadHTTPCode</a>(link);
<a name="l00790"></a>00790             <span class="comment">//writeDebugStreamLine(&quot;HTTP CODE: %d&quot;, getrequest.result_code);</span>
<a name="l00791"></a>00791             done = <span class="keyword">true</span>;
<a name="l00792"></a>00792           }
<a name="l00793"></a>00793           <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#gad89462f276459994f24dfa0dfc8a3968">HRWB_GET_STATUS_REQ_DONE</a>) == HRWB_GET_STATUS_REQ_DONE)
<a name="l00794"></a>00794           {
<a name="l00795"></a>00795             <span class="comment">//writeDebugStreamLine(&quot;SUCCESS GET&quot;);</span>
<a name="l00796"></a>00796             getrequest.<a class="code" href="structt_get_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = <a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">HRWBreadHTTPCode</a>(link);
<a name="l00797"></a>00797             <span class="comment">//writeDebugStreamLine(&quot;HTTP CODE: %d&quot;, getrequest.result_code);</span>
<a name="l00798"></a>00798             done = <span class="keyword">true</span>;
<a name="l00799"></a>00799           }
<a name="l00800"></a>00800           wait1Msec(100);
<a name="l00801"></a>00801         }
<a name="l00802"></a>00802 
<a name="l00803"></a>00803         wait1Msec(1000);
<a name="l00804"></a>00804         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga3a8b05801cca5bb25c82addb9befe569">HRWB_GET_LENGTH</a>, 1))
<a name="l00805"></a>00805           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00806"></a>00806   getrequest.<a class="code" href="structt_get_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a> = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00807"></a>00807 
<a name="l00808"></a>00808   writeDebugStreamLine(<span class="stringliteral">&quot;res length: %d&quot;</span>, getrequest.<a class="code" href="structt_get_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>);
<a name="l00809"></a>00809   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf2d5e1b8236c9b9fb2cf8cea26d48e5f">HRWBreadBigReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga4e4463412c77b1b9fb14fadaff83d3d2">HRWB_GET_DATA</a>, getrequest.<a class="code" href="structt_get_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>))
<a name="l00810"></a>00810     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00811"></a>00811 
<a name="l00812"></a>00812   memcpy(&amp;getrequest.<a class="code" href="structt_get_request.html#a7dd77a48b3fc5e229f5f9db5bee8ca60">RXData</a>[0], &amp;<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>));
<a name="l00813"></a>00813         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00814"></a>00814 
<a name="l00815"></a>00815 
<a name="l00816"></a>00816 }
<a name="l00817"></a>00817 
<a name="l00818"></a>00818 <span class="comment"></span>
<a name="l00819"></a>00819 <span class="comment">/**</span>
<a name="l00820"></a>00820 <span class="comment"> * Perform a HTTP POST transaction</span>
<a name="l00821"></a>00821 <span class="comment"> * @param link the port number</span>
<a name="l00822"></a>00822 <span class="comment"> * @param postrequest tPostRequest struct containing transaction parameters</span>
<a name="l00823"></a>00823 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00824"></a>00824 <span class="comment"> */</span>
<a name="l00825"></a><a class="code" href="group___h_r_w_b.html#gad324d3b8893e2ac825d38bc635c77b59">00825</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#gad324d3b8893e2ac825d38bc635c77b59">HRWBdoPOST</a>(tSensors link, <a class="code" href="structt_post_request.html">tPostRequest</a> &amp;postrequest) {
<a name="l00826"></a>00826   ubyte status = 0;
<a name="l00827"></a>00827   <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
<a name="l00828"></a>00828   ubyte tmpPort[2];
<a name="l00829"></a>00829 
<a name="l00830"></a>00830   tmpPort[0] = (postrequest.<a class="code" href="structt_post_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 8) &amp; 0xFF;
<a name="l00831"></a>00831   tmpPort[1] = (postrequest.<a class="code" href="structt_post_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 0) &amp; 0xFF;
<a name="l00832"></a>00832 
<a name="l00833"></a>00833   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga7f687ee86db4390d1d5cb5271a41548a">HRWB_POST_STATUS</a>, 1);
<a name="l00834"></a>00834   status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00835"></a>00835 
<a name="l00836"></a>00836   <span class="keywordflow">if</span> (status &amp; <a class="code" href="group___h_r_w_b.html#ga17d743fcff07cf727fb6b84fbd4914c3">HRWB_POST_STATUS_READY</a> != <a class="code" href="group___h_r_w_b.html#ga17d743fcff07cf727fb6b84fbd4914c3">HRWB_POST_STATUS_READY</a>)
<a name="l00837"></a>00837     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00838"></a>00838     <span class="comment">//writeDebugStreamLine(&quot;NOT READY&quot;);</span>
<a name="l00839"></a>00839 
<a name="l00840"></a>00840         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, postrequest.<a class="code" href="structt_post_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00841"></a>00841         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga24ae5d966024071b02ce3baee2605d69">HRWB_POST_IP_ADDR</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>)))
<a name="l00842"></a>00842           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00843"></a>00843 
<a name="l00844"></a>00844   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tmpPort, 2);
<a name="l00845"></a>00845         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gac2530c07629b55b57761aa141c774aca">HRWB_POST_PORT</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 2))
<a name="l00846"></a>00846           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00847"></a>00847 
<a name="l00848"></a>00848         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga99cdc2184d7073f1c1f20f60723cadb0">HRWB_POST_URL</a>, (<a class="code" href="group__common.html#gacc2928041c5ff8e7f2ddef1e88431e80">tHugeByteArray</a>)postrequest.<a class="code" href="structt_post_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>, <a class="code" href="group___h_r_w_b.html#gaa11c521e2287b090a4acda9f5d41b87b">strsize</a>(postrequest.<a class="code" href="structt_post_request.html#ad0b5abf5bb825ab2dc948b6c115d85bc">URL</a>) + 1))
<a name="l00849"></a>00849           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00850"></a>00850 
<a name="l00851"></a>00851         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaa8d64c2edecfb8fc26acd1306c68d214">HRWB_POST_DATA</a>, (<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>)postrequest.<a class="code" href="structt_post_request.html#a6c093ddf7de5f28ffed73071e70b1232">TXData</a>[0], postrequest.<a class="code" href="structt_post_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>))
<a name="l00852"></a>00852           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00853"></a>00853 
<a name="l00854"></a>00854         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#ga7f687ee86db4390d1d5cb5271a41548a">HRWB_POST_STATUS</a>, <a class="code" href="group___h_r_w_b.html#gae586eba23c128a4c569bf1b606450613">HRWB_POST_STATUS_SEND_REQ</a>, <a class="code" href="group___h_r_w_b.html#gae586eba23c128a4c569bf1b606450613">HRWB_POST_STATUS_SEND_REQ</a>))
<a name="l00855"></a>00855           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00856"></a>00856 
<a name="l00857"></a>00857         <span class="keywordflow">while</span>(!done) {
<a name="l00858"></a>00858           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga7f687ee86db4390d1d5cb5271a41548a">HRWB_POST_STATUS</a>, 1))
<a name="l00859"></a>00859             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00860"></a>00860           status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00861"></a>00861 
<a name="l00862"></a>00862 
<a name="l00863"></a>00863           <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga7805266f0220885fec9b5194e127d98a">HRWB_POST_STATUS_REQ_ERROR</a>) == HRWB_POST_STATUS_REQ_ERROR)
<a name="l00864"></a>00864           {
<a name="l00865"></a>00865             <span class="comment">//writeDebugStreamLine(&quot;ERROR POST: %d&quot;, status);</span>
<a name="l00866"></a>00866             postrequest.<a class="code" href="structt_post_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = <a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">HRWBreadHTTPCode</a>(link);
<a name="l00867"></a>00867             <span class="comment">//writeDebugStreamLine(&quot;HTTP CODE: %d&quot;, postrequest.result_code);</span>
<a name="l00868"></a>00868             done = <span class="keyword">true</span>;
<a name="l00869"></a>00869           }
<a name="l00870"></a>00870           <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga38ace177506cf66371b447912c5fc8bc">HRWB_POST_STATUS_REQ_DONE</a>) == HRWB_POST_STATUS_REQ_DONE)
<a name="l00871"></a>00871           {
<a name="l00872"></a>00872             <span class="comment">//writeDebugStreamLine(&quot;SUCCESS POST&quot;);</span>
<a name="l00873"></a>00873             postrequest.<a class="code" href="structt_post_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = <a class="code" href="group___h_r_w_b.html#gaab0f1ca8dd6649e946933143e76cb4e2">HRWBreadHTTPCode</a>(link);
<a name="l00874"></a>00874             <span class="comment">//writeDebugStreamLine(&quot;HTTP CODE: %d&quot;, postrequest.result_code);</span>
<a name="l00875"></a>00875             done = <span class="keyword">true</span>;
<a name="l00876"></a>00876           }
<a name="l00877"></a>00877           wait1Msec(100);
<a name="l00878"></a>00878         }
<a name="l00879"></a>00879         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00880"></a>00880 }
<a name="l00881"></a>00881 
<a name="l00882"></a>00882 <span class="comment"></span>
<a name="l00883"></a>00883 <span class="comment">/**</span>
<a name="l00884"></a>00884 <span class="comment"> * Perform a TCP transaction</span>
<a name="l00885"></a>00885 <span class="comment"> * @param link the port number</span>
<a name="l00886"></a>00886 <span class="comment"> * @param tcprequest tTCPRequest struct containing transaction parameters</span>
<a name="l00887"></a>00887 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00888"></a>00888 <span class="comment"> */</span>
<a name="l00889"></a><a class="code" href="group___h_r_w_b.html#ga5a73cc99dfb1aea10520a7154ca7baf9">00889</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga5a73cc99dfb1aea10520a7154ca7baf9">HRWBdoTCP</a>(tSensors link, <a class="code" href="structt_t_c_p_request.html">tTCPRequest</a> &amp;tcprequest) {
<a name="l00890"></a>00890   ubyte status = 0;
<a name="l00891"></a>00891   <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
<a name="l00892"></a>00892   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#gae68063dc3dcad3f215a1d7c076d274b0">HRWB_TCP_STATUS</a>, 1);
<a name="l00893"></a>00893   status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00894"></a>00894   ubyte tmpPort[2];
<a name="l00895"></a>00895 
<a name="l00896"></a>00896   tmpPort[0] = (tcprequest.<a class="code" href="structt_t_c_p_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 8) &amp; 0xFF;
<a name="l00897"></a>00897   tmpPort[1] = (tcprequest.<a class="code" href="structt_t_c_p_request.html#a63c89c04d1feae07ca35558055155ffb">port</a> &gt;&gt; 0) &amp; 0xFF;
<a name="l00898"></a>00898 
<a name="l00899"></a>00899   <span class="keywordflow">if</span> (status &amp; <a class="code" href="group___h_r_w_b.html#gac92fd33aefa1c0f1ef72f865bb631e85">HRWB_TCP_STATUS_READY</a> != <a class="code" href="group___h_r_w_b.html#gac92fd33aefa1c0f1ef72f865bb631e85">HRWB_TCP_STATUS_READY</a>)
<a name="l00900"></a>00900     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00901"></a>00901     <span class="comment">//writeDebugStreamLine(&quot;NOT READY&quot;);</span>
<a name="l00902"></a>00902 
<a name="l00903"></a>00903         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tcprequest.<a class="code" href="structt_t_c_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00904"></a>00904         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga4cfb14cccf826cfc81f6aca739698a2f">HRWB_TCP_IP_ADDR</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> )))
<a name="l00905"></a>00905           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00906"></a>00906 
<a name="l00907"></a>00907   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tmpPort, 2);
<a name="l00908"></a>00908         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga5424ffaf440a8969fb61872b9dd27cc7">HRWB_TCP_PORT</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 2))
<a name="l00909"></a>00909           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00910"></a>00910 
<a name="l00911"></a>00911         writeDebugStreamLine(<span class="stringliteral">&quot;port: %2x %2x&quot;</span>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>[0], <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>[1]);
<a name="l00912"></a>00912 
<a name="l00913"></a>00913         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gae47623c8e63e1ba38d2ef2c607043707">HRWB_TCP_TX_DATA</a>, (<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>)tcprequest.<a class="code" href="structt_t_c_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">TXData</a>[0], tcprequest.<a class="code" href="structt_t_c_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>))
<a name="l00914"></a>00914           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00915"></a>00915 
<a name="l00916"></a>00916         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tcprequest.<a class="code" href="structt_t_c_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>, 1);
<a name="l00917"></a>00917         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gab7316e7c92ab2e4c8512d0b90b12d53e">HRWB_TCP_TX_LENGTH</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 1))
<a name="l00918"></a>00918           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00919"></a>00919 
<a name="l00920"></a>00920         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#gae68063dc3dcad3f215a1d7c076d274b0">HRWB_TCP_STATUS</a>, <a class="code" href="group___h_r_w_b.html#ga0d60f985390f06311e15a4b9dca964bc">HRWB_TCP_STATUS_SEND_REQ</a>, <a class="code" href="group___h_r_w_b.html#ga0d60f985390f06311e15a4b9dca964bc">HRWB_TCP_STATUS_SEND_REQ</a>))
<a name="l00921"></a>00921           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00922"></a>00922 
<a name="l00923"></a>00923         <span class="keywordflow">while</span>(!done) {
<a name="l00924"></a>00924           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#gae68063dc3dcad3f215a1d7c076d274b0">HRWB_TCP_STATUS</a>, 1))
<a name="l00925"></a>00925             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00926"></a>00926           status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00927"></a>00927 
<a name="l00928"></a>00928           <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga3d56950b17a9b8bea98a9bfd88bf2d2b">HRWB_TCP_STATUS_REQ_ERROR</a>) == HRWB_TCP_STATUS_REQ_ERROR)
<a name="l00929"></a>00929           {
<a name="l00930"></a>00930             tcprequest.<a class="code" href="structt_t_c_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = status;
<a name="l00931"></a>00931             done = <span class="keyword">true</span>;
<a name="l00932"></a>00932           }
<a name="l00933"></a>00933           <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#ga4e4dd56280dc0b77981313f42b9c1c3a">HRWB_TCP_STATUS_REQ_DONE</a>) == HRWB_TCP_STATUS_REQ_DONE)
<a name="l00934"></a>00934           {
<a name="l00935"></a>00935             tcprequest.<a class="code" href="structt_t_c_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = 0;
<a name="l00936"></a>00936             done = <span class="keyword">true</span>;
<a name="l00937"></a>00937           }
<a name="l00938"></a>00938           wait1Msec(100);
<a name="l00939"></a>00939         }
<a name="l00940"></a>00940 
<a name="l00941"></a>00941         wait1Msec(100);
<a name="l00942"></a>00942         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga3a3a9e7b5012963750ed7cd5d6ec7de9">HRWB_TCP_RX_LENGTH</a>, 1))
<a name="l00943"></a>00943           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00944"></a>00944   tcprequest.<a class="code" href="structt_t_c_p_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a> = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00945"></a>00945 
<a name="l00946"></a>00946   writeDebugStreamLine(<span class="stringliteral">&quot;res length: %d&quot;</span>, tcprequest.<a class="code" href="structt_t_c_p_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a>);
<a name="l00947"></a>00947   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf2d5e1b8236c9b9fb2cf8cea26d48e5f">HRWBreadBigReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga20a4a2fc472c6a3ddc9b55029c0240a5">HRWB_TCP_RX_DATA</a>, 32))
<a name="l00948"></a>00948     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00949"></a>00949 
<a name="l00950"></a>00950   memcpy(&amp;tcprequest.<a class="code" href="structt_t_c_p_request.html#acec89450ce66e3641999cc2f7e7e338c">RXData</a>[0], &amp;<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>));
<a name="l00951"></a>00951 
<a name="l00952"></a>00952   <span class="comment">//writeDebugStreamLine(&quot; &quot;);</span>
<a name="l00953"></a>00953         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00954"></a>00954 }
<a name="l00955"></a>00955 
<a name="l00956"></a>00956 <span class="comment"></span>
<a name="l00957"></a>00957 <span class="comment">/**</span>
<a name="l00958"></a>00958 <span class="comment"> * Perform a UDP transaction</span>
<a name="l00959"></a>00959 <span class="comment"> * @param link the port number</span>
<a name="l00960"></a>00960 <span class="comment"> * @param udprequest tUDPRequest struct containing transaction parameters</span>
<a name="l00961"></a>00961 <span class="comment"> * @return true if no error occured, false if it did</span>
<a name="l00962"></a>00962 <span class="comment"> */</span>
<a name="l00963"></a><a class="code" href="group___h_r_w_b.html#ga5181928fedfc13ff551e59f19ced6e91">00963</a> <span class="keywordtype">bool</span> <a class="code" href="group___h_r_w_b.html#ga5181928fedfc13ff551e59f19ced6e91">HRWBdoUDP</a>(tSensors link, <a class="code" href="structt_u_d_p_request.html">tUDPRequest</a> &amp;udprequest) {
<a name="l00964"></a>00964   ubyte status = 0;
<a name="l00965"></a>00965   <span class="keywordtype">bool</span> done = <span class="keyword">false</span>;
<a name="l00966"></a>00966   <a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaa2a4e5ec89fd20f725158818684cfe55">HRWB_UDP_STATUS</a>, 1);
<a name="l00967"></a>00967   status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l00968"></a>00968   ubyte tmpsPort[2];
<a name="l00969"></a>00969   ubyte tmpdPort[2];
<a name="l00970"></a>00970 
<a name="l00971"></a>00971 
<a name="l00972"></a>00972   tmpsPort[0] = (udprequest.<a class="code" href="structt_u_d_p_request.html#a32c63c3542a21dfdb3ed1164140c254f">sport</a> &gt;&gt; 8) &amp; 0xFF;
<a name="l00973"></a>00973   tmpsPort[1] = (udprequest.<a class="code" href="structt_u_d_p_request.html#a32c63c3542a21dfdb3ed1164140c254f">sport</a> &gt;&gt; 0) &amp; 0xFF;
<a name="l00974"></a>00974 
<a name="l00975"></a>00975   tmpdPort[0] = (udprequest.<a class="code" href="structt_u_d_p_request.html#a32be3c23ead7f4709d3cece7cfe06d4e">dport</a> &gt;&gt; 8) &amp; 0xFF;
<a name="l00976"></a>00976   tmpdPort[1] = (udprequest.<a class="code" href="structt_u_d_p_request.html#a32be3c23ead7f4709d3cece7cfe06d4e">dport</a> &gt;&gt; 0) &amp; 0xFF;
<a name="l00977"></a>00977 
<a name="l00978"></a>00978   <span class="keywordflow">if</span> (status &amp; <a class="code" href="group___h_r_w_b.html#gac55a869326d86b0a4cecc20764fad834">HRWB_UDP_STATUS_READY</a> != <a class="code" href="group___h_r_w_b.html#gac55a869326d86b0a4cecc20764fad834">HRWB_UDP_STATUS_READY</a>)
<a name="l00979"></a>00979     writeDebugStreamLine(<span class="stringliteral">&quot;NOT READY&quot;</span>);
<a name="l00980"></a>00980 
<a name="l00981"></a>00981         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, udprequest.<a class="code" href="structt_u_d_p_request.html#a3987dc1a3dbba53b106c2ed4332fc364">IP</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a>));
<a name="l00982"></a>00982         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga1ac8093a557d797d279f340ccf268a00">HRWB_UDP_IP_ADDR</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga1c5690729eb47d01453399497a2b3029">tIPaddr</a> )))
<a name="l00983"></a>00983           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00984"></a>00984 
<a name="l00985"></a>00985   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tmpsPort, 2);
<a name="l00986"></a>00986         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaafb3baddc2e5ae7ebe5aadaa8c8825fd">HRWB_UDP_SPORT</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 2))
<a name="l00987"></a>00987           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00988"></a>00988         <span class="comment">//writeDebugStreamLine(&quot;sport: %2x %2x&quot;, HRWB_scratch[0], HRWB_scratch[1]);</span>
<a name="l00989"></a>00989 
<a name="l00990"></a>00990   memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, tmpdPort, 2);
<a name="l00991"></a>00991         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga6dd3ba43103173e49a4a9eecb0a69664">HRWB_UDP_DPORT</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 2))
<a name="l00992"></a>00992           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00993"></a>00993         <span class="comment">//writeDebugStreamLine(&quot;dport: %2x %2x&quot;, HRWB_scratch[0], HRWB_scratch[1]);</span>
<a name="l00994"></a>00994 
<a name="l00995"></a>00995         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga33718caa5501b3432a8104fa47fe43e2">HRWB_UDP_TX_DATA</a>, (<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>)udprequest.<a class="code" href="structt_u_d_p_request.html#afcc9ba355c6dbfbacf29c100c594c22d">TXData</a>[0], udprequest.<a class="code" href="structt_u_d_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>))
<a name="l00996"></a>00996           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00997"></a>00997 
<a name="l00998"></a>00998         memcpy(<a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, udprequest.<a class="code" href="structt_u_d_p_request.html#aa300ad171e0161e703a3d0c770ef09e1">TXDataLen</a>, 1);
<a name="l00999"></a>00999         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga643d47fffcdd8826f2d94ecda790fbfa">HRWBwriteReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga3791be776cf98565408cce1dd1a9b8d1">HRWB_UDP_TX_LENGTH</a>, <a class="code" href="group___h_r_w_b.html#ga951499d71c023fc760a276ac23962c97">HRWB_scratch</a>, 1))
<a name="l01000"></a>01000           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01001"></a>01001 
<a name="l01002"></a>01002         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#ga5e791bb5e1c34d4cfe919890624e0c5f">HRWBwriteRegMasked</a>(link, <a class="code" href="group___h_r_w_b.html#gaa2a4e5ec89fd20f725158818684cfe55">HRWB_UDP_STATUS</a>, <a class="code" href="group___h_r_w_b.html#gacaeeffdcbfe63673d18be3aec8177e56">HRWB_UDP_STATUS_SEND_REQ</a>, <a class="code" href="group___h_r_w_b.html#gacaeeffdcbfe63673d18be3aec8177e56">HRWB_UDP_STATUS_SEND_REQ</a>))
<a name="l01003"></a>01003           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01004"></a>01004 
<a name="l01005"></a>01005         <span class="keywordflow">while</span>(!done) {
<a name="l01006"></a>01006           <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaa2a4e5ec89fd20f725158818684cfe55">HRWB_UDP_STATUS</a>, 1))
<a name="l01007"></a>01007             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01008"></a>01008           status = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l01009"></a>01009 
<a name="l01010"></a>01010           <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#gae2fafb6f65bb3d5eda092236c499f1d7">HRWB_UDP_STATUS_REQ_ERROR</a>) == HRWB_UDP_STATUS_REQ_ERROR)
<a name="l01011"></a>01011           {
<a name="l01012"></a>01012             udprequest.<a class="code" href="structt_u_d_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = status;
<a name="l01013"></a>01013             done = <span class="keyword">true</span>;
<a name="l01014"></a>01014           }
<a name="l01015"></a>01015           <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((status &amp; <a class="code" href="group___h_r_w_b.html#gabc5bb1d4cd7da104af75774cdcf05368">HRWB_UDP_STATUS_REQ_DONE</a>) == HRWB_UDP_STATUS_REQ_DONE)
<a name="l01016"></a>01016           {
<a name="l01017"></a>01017             udprequest.<a class="code" href="structt_u_d_p_request.html#a0bcbf737568b3f83477fd1e521f6c131">result_code</a> = status;
<a name="l01018"></a>01018             done = <span class="keyword">true</span>;
<a name="l01019"></a>01019           }
<a name="l01020"></a>01020           wait1Msec(100);
<a name="l01021"></a>01021         }
<a name="l01022"></a>01022 
<a name="l01023"></a>01023         wait1Msec(100);
<a name="l01024"></a>01024         <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf71121450ff1e1f480bb23b32e1a2a47">HRWBreadReg</a>(link, <a class="code" href="group___h_r_w_b.html#ga25cac5b6ff154c5cb954fd71b590f0c8">HRWB_UDP_RX_LENGTH</a>, 1))
<a name="l01025"></a>01025           <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01026"></a>01026   udprequest.<a class="code" href="structt_u_d_p_request.html#a751d3070e77ef824ec375a233d8cde1a">RXDataLen</a> = <a class="code" href="group___h_r_w_b.html#ga159b1f66b5aaf1d8cec3842d8bacff82">HRWB_I2CReply</a>[0];
<a name="l01027"></a>01027 
<a name="l01028"></a>01028   <span class="comment">//writeDebugStreamLine(&quot;res length: %d&quot;, udprequest.RXDataLen);</span>
<a name="l01029"></a>01029   <span class="keywordflow">if</span> (!<a class="code" href="group___h_r_w_b.html#gaf2d5e1b8236c9b9fb2cf8cea26d48e5f">HRWBreadBigReg</a>(link, <a class="code" href="group___h_r_w_b.html#gaed05706029146c07f0fb8c628916e6a1">HRWB_UDP_RX_DATA</a>, 32))
<a name="l01030"></a>01030     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01031"></a>01031 
<a name="l01032"></a>01032   memcpy(&amp;udprequest.<a class="code" href="structt_u_d_p_request.html#acec89450ce66e3641999cc2f7e7e338c">RXData</a>[0], &amp;<a class="code" href="group___h_r_w_b.html#ga1f34cde17c2282cd05e9db19576b3f9b">HRWB_HugeArray</a>[0], <span class="keyword">sizeof</span>(<a class="code" href="group__common.html#ga54b6c60d5d8ec411391ca920bf8dc97b">tBigByteArray</a>));
<a name="l01033"></a>01033 
<a name="l01034"></a>01034   <span class="comment">//writeDebugStreamLine(&quot; &quot;);</span>
<a name="l01035"></a>01035         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01036"></a>01036 }
<a name="l01037"></a>01037 
<a name="l01038"></a>01038 
<a name="l01039"></a>01039 <span class="preprocessor">#endif // __HRWB_H__</span>
<a name="l01040"></a>01040 <span class="preprocessor"></span>
<a name="l01041"></a>01041 <span class="comment">/*</span>
<a name="l01042"></a>01042 <span class="comment"> * $Id: humarobotics-wifiblock.h 133 2013-03-10 15:15:38Z xander $</span>
<a name="l01043"></a>01043 <span class="comment"> */</span>
<a name="l01044"></a>01044 <span class="comment">/* @} */</span>
<a name="l01045"></a>01045 <span class="comment">/* @} */</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:43 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
